snowflakedb / snowflakedb/snowflake-connector-python

SNOW-823151: First result batch has int64 arrow type for NUMBER column with real values

Open
#1,568 12 comments 1 reaction 1 assignee View on GitHub

@sfc-gh-aling is already working on this.

Since Mar 24, 2024.

bug status-triage_done
Dominant language
Python
Stars
730
Forks
574
Avg merge
5h 45m
Merged PRs (30d)
16

Description

When fetching multiple batches via get_result_batches , the first batch is empty and has the incorrect arrow data type for NUMBER columns containing real values, eg:

import snowflake.connector
import pyarrow

conn = snowflake.connector.connect(... )
cur = conn.cursor()
cur.execute("SELECT cast(1.5 as NUMBER(32,4)) as AMOUNT;")
batches = cur.get_result_batches()
batch = batches[0]
# the first batch is normally empty, which triggers _create_empty_table
# in this MRE we trigger it explicitly to demonstrate the error 
table = batch._create_empty_table()
print(table.schema)

assert table.schema.types[0] == pyarrow.float64()

Will fail with an assertion error and output:

AMOUNT: int64

snowflake-connector-python==3.0.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.