Skip to content

Commit 614f938

Browse files
committed
fix: convert regex sql to postgres
1 parent 2f6830a commit 614f938

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pygwalker/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pygwalker.services.global_var import GlobalVarManager
1111
from pygwalker.services.kaggle import show_tips_user_kaggle as __show_tips_user_kaggle
1212

13-
__version__ = "0.4.8.7"
13+
__version__ = "0.4.8.8"
1414
__hash__ = __rand_str()
1515

1616
from pygwalker.api.jupyter import walk, render, table

pygwalker/utils/custom_sqlglot.py

+8
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,20 @@ def _postgres_str_to_time_sql(self: Generator, expression: exp.StrToTime) -> str
9090
return self.func("TO_TIMESTAMP", expression.this, self.format_time(expression))
9191

9292

93+
def _postgres_regexp_like_sql(self: Generator, expression: exp.RegexpLike) -> str:
94+
flag = expression.args.get("flag")
95+
if flag and flag.this == "i":
96+
return self.binary(expression, "~*")
97+
return self.binary(expression, "~")
98+
99+
93100
PostgresDialect.Generator.TRANSFORMS[exp.Round] = lambda _, e: _postgres_round_generator(e)
94101
PostgresDialect.Generator.TRANSFORMS[exp.UnixToTime] = _postgres_unix_to_time_sql
95102
PostgresDialect.Generator.TRANSFORMS[exp.In] = _postgres_in_sql
96103
PostgresDialect.Generator.TRANSFORMS[exp.TimestampTrunc] = _postgres_timestamp_trunc
97104
PostgresDialect.Generator.TRANSFORMS[exp.TimeToStr] = _postgres_time_to_str_sql
98105
PostgresDialect.Generator.TRANSFORMS[exp.StrToTime] = _postgres_str_to_time_sql
106+
PostgresDialect.Generator.TRANSFORMS[exp.RegexpLike] = _postgres_regexp_like_sql
99107

100108

101109
# Mysql Dialect

0 commit comments

Comments
 (0)