Skip to content

fix(postgres): ignore non-select queries - #252

Merged
houqp merged 1 commit into
roapi:mainfrom
houqp:qp_postgres
Jan 29, 2023
Merged

houqp merged 1 commit into
roapi:mainfrom
houqp:qp_postgres

Conversation

@houqp

@houqp houqp commented Jan 28, 2023 •

Copy link
Copy Markdown
Member

closes #180

@houqp
houqp requested a review from jychen7 January 28, 2023 15:16
@houqp
houqp enabled auto-merge (squash) January 28, 2023 15:16
@houqp
houqp force-pushed the qp_postgres branch 2 times, most recently from c356e4e to 3e45071 Compare January 28, 2023 15:25
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) {

Copy link
Copy Markdown
Collaborator

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 })

Copy link
Copy Markdown
Member Author

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.

@houqp
houqp merged commit 90e79dc into roapi:main Jan 29, 2023
@houqp
houqp deleted the qp_postgres branch January 29, 2023 02:59
@jychen7

jychen7 commented Jan 29, 2023

Copy link
Copy Markdown
Collaborator

enabled auto-merge (squash)

lol, that's why so instant

Ok(DataFusionPortal {
df: self
.ctx
.sql_to_df("SELECT 1 WHERE 1 = 2")

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Member Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roapi postgres support - JDBC driver fails due to issuing Postgres session command to set extra float digits

2 participants