Skip to content

Commit 9365ac8

Browse files
authored
fix(go/adbc/driver/snowflake): Boolean columns return as string types in an empty recordset schema (#2854)
When the user runs a query that does not return a record set, ie: ``` select * from (SELECT CAST(TRUE as BOOLEAN) as BOOLEANTYPE) as \"_\" where 0 = 1 ``` the boolean column was being identified as a string column. One example of this public issue: https://www.reddit.com/r/PowerBI/comments/1kqhywe/comment/mttjia5/?context=3&share_id=Wr1PAx4F7KemsyQrCVnDK&utm_content=1&utm_medium=ios_app&utm_name=ioscss&utm_source=share&utm_term=1 Co-authored-by: David Coe <>
1 parent 4c036e1 commit 9365ac8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

go/adbc/driver/snowflake/driver_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,23 @@ func (suite *SnowflakeTests) TestTimestampSnow() {
16801680
}
16811681
}
16821682

1683+
func (suite *SnowflakeTests) TestBooleanType() {
1684+
suite.Require().NoError(suite.stmt.SetSqlQuery("select * from (SELECT CAST(TRUE as BOOLEAN) as BOOLEANTYPE) as \"_\" where 0 = 1"))
1685+
rdr, _, err := suite.stmt.ExecuteQuery(suite.ctx)
1686+
suite.Require().NoError(err)
1687+
defer rdr.Release()
1688+
1689+
for _, f := range rdr.Schema().Fields() {
1690+
st, ok := f.Metadata.GetValue("SNOWFLAKE_TYPE")
1691+
if !ok {
1692+
continue
1693+
}
1694+
if st == "boolean" {
1695+
suite.Require().IsType(&arrow.BooleanType{}, f.Type)
1696+
}
1697+
}
1698+
}
1699+
16831700
func (suite *SnowflakeTests) TestUseHighPrecision() {
16841701
suite.Require().NoError(suite.Quirks.DropTable(suite.cnxn, "NUMBERTYPETEST"))
16851702

go/adbc/driver/snowflake/record_reader.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ func rowTypesToArrowSchema(_ context.Context, ld gosnowflake.ArrowStreamLoader,
343343
fields[i].Type = &arrow.TimestampType{Unit: arrow.Nanosecond, TimeZone: loc.String()}
344344
case "binary":
345345
fields[i].Type = arrow.BinaryTypes.Binary
346+
case "boolean":
347+
fields[i].Type = arrow.FixedWidthTypes.Boolean
346348
default:
347349
fields[i].Type = arrow.BinaryTypes.String
348350
}

0 commit comments

Comments
 (0)