Skip to content

Commit

Permalink
refactor(snowflake): sort column names in the database instead of on …
Browse files Browse the repository at this point in the history
…the client
  • Loading branch information
cpcloud committed Sep 1, 2023
1 parent bb7fa32 commit fb52814
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ibis/backends/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import tempfile
import textwrap
import warnings
from operator import itemgetter
from pathlib import Path
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -671,6 +670,7 @@ def read_csv(
con.exec_driver_sql(
f"""
SELECT ARRAY_AGG(OBJECT_CONSTRUCT(*))
WITHIN GROUP (ORDER BY ORDER_ID ASC)
FROM TABLE(
INFER_SCHEMA(
LOCATION => '@{stage}',
Expand All @@ -682,7 +682,7 @@ def read_csv(
)
fields = [
(self._quote(field["COLUMN_NAME"]), field["TYPE"], field["NULLABLE"])
for field in sorted(fields, key=itemgetter("ORDER_ID"))
for field in fields
]
columns = ", ".join(
f"{quoted_name} {typ}{' NOT NULL' * (not nullable)}"
Expand Down Expand Up @@ -754,6 +754,7 @@ def read_json(
CREATE TEMP TABLE {qtable}
USING TEMPLATE (
SELECT ARRAY_AGG(OBJECT_CONSTRUCT(*))
WITHIN GROUP (ORDER BY ORDER_ID ASC)
FROM TABLE(
INFER_SCHEMA(
LOCATION => '@{stage}',
Expand Down

0 comments on commit fb52814

Please sign in to comment.