-
Notifications
You must be signed in to change notification settings - Fork 231
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
feat: editor awareness of default schemas #1422
base: master
Are you sure you want to change the base?
Conversation
@jczhong84 thanks again for taking a look! |
connection_string = self.executor_params.get("connection_string") | ||
try: | ||
connection_url = sql.engine.make_url(connection_string) | ||
except Exception: | ||
connection_url = None | ||
|
||
if connection_url: | ||
default_schema = connection_url.database or default_schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not all the connection strings have the database, I think it will be better to have a seprate executor param for the default schema.
possible_schema = prefix.split(".")[0] | ||
omit_schema = not active_schema.startswith(possible_schema) | ||
|
||
query = construct_suggest_table_query(prefix, limit, metastore_id) | ||
options = get_matching_suggestions(query, ES_CONFIG["tables"]["index_name"]) | ||
texts = [ | ||
"{}.{}".format( | ||
option.get("_source", {}).get("schema", ""), | ||
option.get("_source", {}).get("name", ""), | ||
( | ||
option.get("_source", {}).get("name", "") | ||
if omit_schema and active_schema == option.get("_source", {}).get("schema", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I'm following what this active_schema and this omit_schema is trying to do here. could you elaborate a bit?
@@ -807,6 +813,7 @@ export function findTableReferenceAndAlias(statements: IToken[][]) { | |||
return { | |||
references, | |||
aliases, | |||
activeSchema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like activeSchema
is just the same as defaultSchema
, you dont need to define a new variable, but just return the defaultSchema.
@@ -240,9 +240,12 @@ export class SqlAutoCompleter { | |||
return []; | |||
} | |||
|
|||
let omit_schema = this.codeAnalysis.lineage.activeSchema || 'default'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
. also || default
is not necessarily needed, as the API has the default value default
for the 3rd parameter. could be just below
suggest(
metastoreId,
prefix,
this.codeAnalysis.lineage.activeSchema)
@alexgann sorry for not looking it sooner. thanks for the demo and PR! this will be quite useful. left some comments |
Video Demo/Explanation of Feature: https://youtu.be/w0z4pU_E0bM
Issue
QueryBook QueryEditor is unaware of QueryEngine Connection URI's Default/Named database/schema
Resolution (see video for walkthrough):
Add simple get_default_schema method to QueryEngine python model to parse any provided default schema on the connection URI
Make this defaultSchema known to the front-end for Linting, Analysis, and AutoCompletion
Retain support for use statements and explicit schemas when needed, and no-op to implicit "default" schema name when not provided