jwills / buenavista

A Postgres Proxy Server in Python
Apache License 2.0
201 stars 20 forks source link

Not properly rewritten REGEXP query #30

Closed rzykov closed 2 months ago

rzykov commented 2 months ago

I'm trying to send regexp queries to a duckdb database via buenavista. But buenavista removes 'g' flag from the function:

INFO:buenavista.postgres:Input SQL: select regexp_replace('mr .', '[^a-zA-Z]', '', 'g') INFO:buenavista.postgres:Rewritten SQL: SELECT REGEXP_REPLACE('mr .', '[^a-zA-Z]', '')

jwills commented 2 months ago

Huh that's odd-- I wonder if that is a sqlglot thing, let me try it right quick

jwills commented 2 months ago

yep, it's sqlglot:

>>> sqlglot.transpile("select regexp_replace('mr .', '[^a-zA-Z]', '', 'g')", read="postgres", write="duckdb")[0]
"SELECT REGEXP_REPLACE('mr .', '[^a-zA-Z]', '')"

let's let them know, assuming that is in fact the wrong thing to do?

rzykov commented 2 months ago

@jwills thank you for checking! Let me submit an issue!

rzykov commented 2 months ago

By the way, I'm using the buenavista in production for my project :) slide 18 https://docs.google.com/presentation/d/1FwRPP3-O_0t5Xyg0DDB1WccJ8Mnj6pcMkh9W0s2Y_1g/edit?usp=sharing

rzykov commented 2 months ago

https://github.com/tobymao/sqlglot/issues/3393 Let's wait

rzykov commented 2 months ago

It was resolved