Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add force_ctas_schema to query model when enabled #1825

Merged
merged 3 commits into from
Dec 15, 2016

Conversation

vera-liu
Copy link
Contributor

@vera-liu vera-liu commented Dec 13, 2016

Before:

  • force_ctas_schema is not passed to Query model when enabled, the output column of Query Table does not receive schema from backend unless it is set in query editor

After:

  • when force_ctas_schema is set, it gets stored in query, and will be displayed in output column of QueryHistory if the query was run using ctas

Tested in staging:

  • Use case one: run query with selected schema in left pane
  1. set schema in sql editor left pane
  2. run a query
  3. schema is shown in output column of Query History
  • Use case two: run query with ctas on a database with force_ctas_schema
  1. set schema in database view
  2. run a query using ctas
  3. schema.table_name is shown in output column of Query History
  • Use case three: run query with selected schema and ctas
  1. set schema in sql editor left pane
  2. run a query using ctas
  3. schema.table_name is shown in output column of Query History

Todo:

@@ -2383,12 +2383,16 @@ def table_accessible(database, full_table_name, schema_name=None):
get_datasource_access_error_msg('{}'.format(rejected_tables)))
session.commit()

select_as_cta = request.form.get('select_as_cta') == 'true'
if select_as_cta and mydb.force_ctas_schema:
schema = mydb.force_ctas_schema
Copy link
Member

@bkyryliuk bkyryliuk Dec 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid it could break sql lab.
schema for this endpoint should be one selected in the drop down menu.
mydb.force_ctas_schema needs to be passed to the select * query that is created to get the results of the cta query I believe.

@bkyryliuk
Copy link
Member

@vera-liu - please add a test plan to features
it simplifies the review process and explains how the feature was tested

@vera-liu
Copy link
Contributor Author

Added @bkyryliuk

@vera-liu
Copy link
Contributor Author

After discussing with Max, I add schema to temp_table_name before adding query, so that the actual schema used is shown in output column of Query History. PTAL @bkyryliuk

@@ -105,7 +103,7 @@ def handle_error(msg):
query.user_id,
start_dttm.strftime('%Y_%m_%d_%H_%M_%S'))
executed_sql = create_table_as(
executed_sql, query.tmp_table_name, database.force_ctas_schema)
executed_sql, query.tmp_table_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment that tmp_table_name includes schema here

if select_as_cta and mydb.force_ctas_schema:
tmp_table_name = '{}.{}'.format(
mydb.force_ctas_schema,
tmp_table_name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could u please add a unit test to the celery tests?

@bkyryliuk
Copy link
Member

LGTM

@vera-liu vera-liu merged commit e06a0cd into apache:master Dec 15, 2016
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.15.1 labels Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.15.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants