-
Notifications
You must be signed in to change notification settings - Fork 208
fix(postgres): ignore non-select queries #252
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
Conversation
c356e4e to
3e45071
Compare
| let query = statement.to_string(); | ||
| let df = self.ctx.sql_to_df(&query).await.map_err(df_err_to_sql)?; | ||
| Ok(DataFusionPortal { df }) | ||
| if RoapiContextEngine::<H>::ignored_statement(statement) { |
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.
[minor] will following cleaner if modify slightly?
let query = if RoapiContextEngine::<H>::ignored_statement(statement) {
"SELECT 1 WHERE 1 = 2".to_string()
} else {
statement.to_string()
};
let df = self.ctx.sql_to_df(&query).await.map_err(df_err_to_sql)?;
Ok(DataFusionPortal { df })
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.
yeah i agree. I think ideally, we create an empty dataframe in the ignore branch instead of using a workaround query to avoid unnecessary query parsing and execution.
lol, that's why so instant |
| Ok(DataFusionPortal { | ||
| df: self | ||
| .ctx | ||
| .sql_to_df("SELECT 1 WHERE 1 = 2") |
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.
If I understand correctly, where 1 = 2 is added to make sure return empty result
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.
yeah, it's hacky, if you have better ideas, let me know!
closes #180