Skip to content
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

feat: update duckdb version #438

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pygwalker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pygwalker.services.global_var import GlobalVarManager
from pygwalker.services.kaggle import show_tips_user_kaggle as __show_tips_user_kaggle

__version__ = "0.4.6"
__version__ = "0.4.7a0"
__hash__ = __rand_str()

from pygwalker.api.walker import walk
Expand Down
28 changes: 3 additions & 25 deletions pygwalker/data_parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import abc
import io

from sqlglot import column as column_func
import duckdb
import arrow
import pytz
Expand Down Expand Up @@ -157,35 +156,14 @@ def _infer_prop(
}

def get_datas_by_sql(self, sql: str) -> List[Dict[str, Any]]:
"""
Due to duckdb don't support use 'EPOCH FROM' timestamp_s, timestamp_ms.
So we need to convert timestamp_s, timestamp_ms to timestamp temporarily.
"""
"""get datas by duckdb"""
try:
duckdb.query("SET TimeZone = 'UTC'")
except Exception:
pass

duckdb.register("__pygwalker_mid_table", self._duckdb_df)

select_expr_list = []
for field in self.field_metas:
origin_field = str(column_func(field["key"], quoted=True))
if field["type"] != "datetime":
select_expr_list.append(origin_field)
else:
select_expr_list.append(f'{origin_field}::timestamp {origin_field}')
select_expr = ",".join(select_expr_list)

sql = f"""
WITH pygwalker_mid_table AS (
SELECT
{select_expr}
FROM
"__pygwalker_mid_table"
)
{sql}
"""
duckdb.register("pygwalker_mid_table", self._duckdb_df)

result = duckdb.query(sql)
return [
dict(zip(result.columns, row))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = [
"ipywidgets",
"pydantic",
"psutil",
"duckdb==0.9.2",
"duckdb==0.10.0",
"pyarrow",
"sqlglot>=19.0.0",
"requests",
Expand Down
Loading