-
Notifications
You must be signed in to change notification settings - Fork 262
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
Use statement #936
Use statement #936
Conversation
@xzdandy @gaurav274 You can give read about the design. I will add more implementations to check in binder/catalog. |
For use query, we have the option to skip the binder and optimizer using SKIP_BINDER_AND_OPTIMIZER_STATEMENTS. This can simplify the implementation. |
I meant just checking if the data source is valid. Not gonna check anything for the native query. |
@@ -172,11 +174,19 @@ explain_statement: EXPLAIN explainable_statement | |||
|
|||
explainable_statement : select_statement | insert_statement | update_statement | delete_statement | create_table | |||
|
|||
// Context Statements | |||
|
|||
use_statement: USE database_name "{" query_string "}" // One shortcoming that query string cannot have parenthesis |
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.
Is this the limitation of the lark or ? Why we can not have parenthesis?
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 will remove this comment. The native query can have parenthesis after I change to use curly bracket if that makes sense
// now
USE postgres {
// some query
}
// before
USE postgres (
// some query
)
If I use the parenthesis and the native query has arbitrary parentheses as well, I have some trouble of coming up with a grammar that works for all cases.
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.
Let me take care of it
evadb/optimizer/operators.py
Outdated
@@ -1239,3 +1240,37 @@ def __hash__(self) -> int: | |||
self.search_query_expr, | |||
) | |||
) | |||
|
|||
|
|||
class LogicalUse(Operator): |
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.
Can you also bypass optimizer for use? Just to simplify the code
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.
Will push the code to take care of this
engine = create_engine(conn_str) | ||
|
||
with engine.connect() as con: | ||
if "SELECT" in self._query_string or "select" in self._query_string: |
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.
We need to make this robust for cases where select is used for creating tables etc. Also, if query contains Select
etc
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.
What is the output for CREATE TABLE
from sqlalchemy? Is it possible to simply execute the query and yield whatever output sqlalchemy yields in dataframe type?
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 like this idea
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.
How about we replicate this? https://github.com/mindsdb/mindsdb/blame/b417ecff78cca2e7f09d4e7daa3461595c77ad0d/mindsdb/integrations/handlers/postgres_handler/postgres_handler.py
I'm using it in the other PR for testing the connection.
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.
sqlalchemy/sqlalchemy#5433 (comment)
Based on what I see, it is still true for this API for latest SQLAlchemy. There is no rows returned besides SELECT
.
Working example