hello team, kind of new using daft, and I was faci...
# general
m
hello team, kind of new using daft, and I was facing some error, is this the right place to ask them?
if yes, I am trying to pass a postgres query to the daft.read_sql method and this query contains regular expression for include and exclude filter (check below):
SELECT count(*)
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE concat(current_database(), concat('.', N.nspname)) !~ '^$'
AND concat(current_database(), concat('.', N.nspname)) ~ '.*'
AND N.nspname NOT IN ('performance_schema', 'information_schema') AND N.nspname NOT LIKE 'pg_%%'
AND C.relkind IN ('r','p','v','m','f')
and i am getting this error :
Invalid expression / Unexpected token. Line 5, Col: 60.
mespace N ON (N.oid = C.relnamespace)
WHERE concat(current_database(), concat('.', N.nspname)) !~ '{normalized_exclude_regex}'
AND concat(current_database(), concat('.', N.nspname)) ~ '{nor
can someone help me resolve this?
this works fine with
pandas.read_sql_query
command
c
For context, we use https://github.com/tobymao/sqlglot for parsing sql, and it looks like its an error on their end. Example:
Copy code
import sqlglot

sql = """
SELECT count(*)
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE concat(current_database(), concat('.', N.nspname)) !~ '^$' 
  AND concat(current_database(), concat('.', N.nspname)) ~ '.*' 
  AND N.nspname NOT IN ('performance_schema', 'information_schema') 
  AND N.nspname NOT LIKE 'pg_%' 
  AND C.relkind IN ('r','p','v','m','f')
"""

print(sqlglot.parse_one(sql).sql())

sqlglot.errors.ParseError: Invalid expression / Unexpected token. Line 5, Col: 59.
  g_namespace N ON (N.oid = C.relnamespace)
WHERE concat(current_database(), concat('.', N.nspname)) !~ '^$' 
  AND concat(current_database(), concat('.', N.nspname)) ~ '.*' 
  AND N.nspname NOT IN ('per
For now, could you try to use the `REGEXP_MATCHES`egex expressions? e.g.
WHERE REGEXP_MATCHES(concat(current_database(), '.', N.nspname), '^$') IS NULL  AND REGEXP_MATCHES(concat(current_database(), '.', N.nspname), '.*') IS NOT NULL
m
okay i've seen an issue being raised and merged with the similar issue
🙌 1