Skip to content

Commit f77ef01

Browse files
vuanhphungIsaac
andcommitted
fix: render Thrift complex values in linear time
Render nested Thrift ARRAY, MAP and STRUCT values into a shared byte buffer instead of repeatedly copying growing strings, making wide results linear while preserving their existing text representation. Fixes #596 Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 319b145 commit f77ef01

6 files changed

Lines changed: 677 additions & 110 deletions

File tree

‎.github/workflows/nightly-e2e.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
DATABRICKS_PECOTESTING_TOKEN_PERSONAL: ${{ secrets.DATABRICKS_PECOTESTING_TOKEN_PERSONAL }}
9191
run: |
9292
go test -tags e2e -count=1 -v -timeout 15m \
93-
-run 'TestE2EArrow(SchemaBeforeFetching|BatchesSurviveQueryContextCancellation)|TestE2ECloudFetchExactRowCount|TestE2ECloudFetchNonPositiveMaxDownloadThreads|TestE2EDecimalMetadata|TestE2EVariantTypeName|TestE2EGeospatialTypeNames|^TestE2ETime(Results|ArrowResults)$|TestE2ERejectedRequestClosesResponse' .
93+
-run 'TestE2EArrow(SchemaBeforeFetching|BatchesSurviveQueryContextCancellation)|TestE2ECloudFetchExactRowCount|TestE2ECloudFetchNonPositiveMaxDownloadThreads|TestE2EDecimalMetadata|TestE2EComplexRendering|TestE2EVariantTypeName|TestE2EGeospatialTypeNames|^TestE2ETime(Results|ArrowResults)$|TestE2ERejectedRequestClosesResponse' .
9494
9595
kernel-e2e:
9696
name: E2E (kernel backend)

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Driver changes
66

7+
- Render Thrift ARRAY, MAP and STRUCT values in linear time (databricks/databricks-sql-go#596).
78
- **Behavior change:** Bound each whole-transfer Thrift CloudFetch download attempt, including `WithTransport`, by the existing 900s `ClientTimeout`, and omit the link's presigned query string from download errors (databricks/databricks-sql-go#475).
89
- **Behavior change:** Without direct results, `ArrowIPCStreamIterator.SchemaBytes()` and `ArrowBatchIterator.Schema()` now retrieve result metadata without fetching data and return the result schema, including for empty results, and can return request or schema-conversion errors. Schemas inferred from Thrift metadata may differ from CloudFetch file schemas when server ArrowSchema is absent (databricks/databricks-sql-go#312).
910
- Evict kernel connections when SEA reports a missing or invalid session, and reject later requests locally without replaying the failed statement.

‎driver_e2e_test.go‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,37 @@ import (
3737
"github.com/stretchr/testify/require"
3838
)
3939

40+
func TestE2EComplexRendering(t *testing.T) {
41+
host, httpPath, token := pecoTestingCreds(t)
42+
connector, err := NewConnector(WithServerHostname(host), WithHTTPPath(httpPath), WithAccessToken(token))
43+
require.NoError(t, err)
44+
db := sql.OpenDB(connector)
45+
t.Cleanup(func() { require.NoError(t, db.Close()) })
46+
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
47+
defer cancel()
48+
result, err := db.QueryContext(ctx, `SELECT
49+
transform(sequence(0, 1535), x -> CAST(x AS DOUBLE) / 7 - 0.5D),
50+
map(1, array(1.25D, NULL), 2, array()),
51+
named_struct('items', array(named_struct('id', 1, 'text', 'a"<>&')),
52+
'lookup', map('key', array(1, NULL, 3)))`)
53+
require.NoError(t, err)
54+
defer func() { require.NoError(t, result.Close()) }()
55+
require.True(t, result.Next(), "%v", result.Err())
56+
var wide, mapping, nested string
57+
require.NoError(t, result.Scan(&wide, &mapping, &nested))
58+
values := make([]float64, 1536)
59+
for index := range values {
60+
values[index] = float64(index)/7 - 0.5
61+
}
62+
expected, err := json.Marshal(values)
63+
require.NoError(t, err)
64+
require.Equal(t, string(expected), wide)
65+
require.Equal(t, `{"1":[1.25,null],"2":[]}`, mapping)
66+
require.Equal(t, `{"items":[{"id":1,"text":"a\"\u003c\u003e\u0026"}],"lookup":{"key":[1,null,3]}}`, nested)
67+
require.False(t, result.Next())
68+
require.NoError(t, result.Err())
69+
}
70+
4071
func TestE2EDecimalMetadata(t *testing.T) {
4172
host, httpPath, token := pecoTestingCreds(t)
4273
for _, native := range []bool{false, true} {

0 commit comments

Comments
 (0)