Skip to content

Commit 9e221fa

Browse files
committed
changelog, make infer_schema column ordering the default behavior
1 parent cb491d6 commit 9e221fa

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#### Improvements
1212

13+
- Improved `DataFrameReader` to return columns in deterministic order when using `INFER_SCHEMA`.
14+
1315
### Snowpark pandas API Updates
1416

1517
#### New Features

src/snowflake/snowpark/_internal/analyzer/analyzer_utils.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,13 +1302,11 @@ def infer_schema_statement(
13021302
path: str,
13031303
file_format_name: str,
13041304
options: Optional[Dict[str, str]] = None,
1305-
ordered: bool = True,
13061305
) -> str:
13071306
"""
1308-
Note: If ordered is set to True (default), results are ordered by ORDER_ID and
1309-
COLUMN_NAME for deterministic column ordering. Set to False to disable ordering.
1307+
Note: Results are ordered by ORDER_ID and COLUMN_NAME for deterministic column ordering.
13101308
"""
1311-
base_query = (
1309+
return (
13121310
SELECT
13131311
+ STAR
13141312
+ FROM
@@ -1335,13 +1333,10 @@ def infer_schema_statement(
13351333
)
13361334
+ RIGHT_PARENTHESIS
13371335
+ RIGHT_PARENTHESIS
1336+
+ ORDER_BY
1337+
+ "ORDER_ID, COLUMN_NAME"
13381338
)
13391339

1340-
if ordered:
1341-
base_query += ORDER_BY + "ORDER_ID, COLUMN_NAME"
1342-
1343-
return base_query
1344-
13451340

13461341
def file_operation_statement(
13471342
command: str, file_name: str, stage_location: str, options: Dict[str, str]

0 commit comments

Comments
 (0)