Skip to content

Commit

Permalink
Updated the tableau_documents publishin examples. Changed the set_fir…
Browse files Browse the repository at this point in the history
…st_custom_sql method to just set_custom_sql (there can only be one in a data source).
  • Loading branch information
Bryant Howell committed Dec 9, 2019
1 parent 801c4f7 commit 66e0f71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/template_publish_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def promote_from_dev_to_test(logger_obj=None):
dses = t_file.datasources
for d in dses:
# You can do things here on the data source itself (change the main table name or custom SQL)

# See test_suite_tableau_documents for examples of these changes
# Connection properties live within the connections collection, and can be read or modified
for conn in d.connections:
print(conn.connection_type)
Expand Down
7 changes: 7 additions & 0 deletions examples/test_suite_tableau_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ def live_db_connection_changes():
if ds.is_stored_proc is False:
if ds.main_table_type == 'table':
ds.tables.main_table_name = '[some other table]'
elif ds.main_table_type == 'custom-sql':
ds.tables.set_first_custom_sql('SELECT * FROM table t1 JOIN table2 t2 ON t1.id = t2.id AND t2.active_flag IS TRUE')
# Stored proc case
else:
ds.tables.set_stored_proc(stored_proc_name='best_stored_proc')
ds.tables.set_stored_proc_parameter_value_by_name('@Param1', 'ID190993')
ds.tables.set_stored_proc_parameter_value_by_name('@Param2', 'West')
for conn in ds.connections:
conn.connection_name = 'Changed Connection Name'
t_file.save_new_file('New TDS')
Expand Down
4 changes: 2 additions & 2 deletions tableau_documents/table_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ def set_first_custom_sql(self, custom_sql: str, table_alias: str, connection: Op
connection = self.main_table.get('connection')
self.main_table = self.create_custom_sql_relation(custom_sql, table_alias, connection=connection)

def set_first_stored_proc(self, stored_proc_name: str, table_alias: str, connection: Optional[str] = None):
def set_stored_proc(self, stored_proc_name: str, connection: Optional[str] = None):
self.ds_generator = True
if self.main_table is not None and connection is None:
connection = self.main_table.get('connection')
self.main_table = self.create_stored_proc_relation(stored_proc_name, table_alias)
self.main_table = self.create_stored_proc_relation(stored_proc_name)

def get_stored_proc_parameter_value_by_name(self, parameter_name: str) -> str:
if self._stored_proc_parameters_xml is None:
Expand Down

0 comments on commit 66e0f71

Please sign in to comment.