Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1313648 GO - Verify value bindings for all field types while exceeding CLIENT_STAGE_ARRAY_BINDING_THRESHOLD #1297

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

sfc-gh-ext-simba-jy
Copy link
Collaborator

@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy commented Jan 31, 2025

Description

SNOW-313648 Please explain the changes you made here.

  • Fixed the time difference when the timestamp value is before 1600
  • Add testing to validate that inserting data with the stage binding, array binding, and interface array binding are the same.

Checklist

  • Created tests which fail without the change (if possible)
  • Extended the README / documentation, if necessary

Copy link

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.19%. Comparing base (e926883) to head (8f8b1a4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1297      +/-   ##
==========================================
- Coverage   82.20%   82.19%   -0.01%     
==========================================
  Files          55       55              
  Lines       13636    13657      +21     
==========================================
+ Hits        11209    11225      +16     
- Misses       2427     2432       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy marked this pull request as ready for review February 5, 2025 22:31
@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy requested a review from a team as a code owner February 5, 2025 22:31
@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy changed the title SNOW-1313648 SNOW-1313648 GO - Verify value bindings for all field types while exceeding CLIENT_STAGE_ARRAY_BINDING_THRESHOLD Feb 6, 2025
@@ -874,6 +874,132 @@ func TestBulkArrayBinding(t *testing.T) {
})
}

func TestSNOW1313648(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a better name?

@@ -874,6 +874,132 @@ func TestBulkArrayBinding(t *testing.T) {
})
}

func TestSNOW1313648(t *testing.T) {
arrayInsertTable := "Snow1313648Insert"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the same, this is just a regular feature that we can name instead of using Jira ID.

interfaceArrayTable := "Snow1313648stageInterface"

runDBTest(t, func(dbt *DBTest) {
dbt.mustExec(fmt.Sprintf("create or replace table %v (c1 integer, c2 string, c3 timestamp_ltz, c4 timestamp_tz, c5 timestamp_ntz, c6 date, c7 time, c8 binary)", arrayInsertTable))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also boolean and double?

someTime := time.Date(1, time.January, 1, 12, 34, 56, 123456789, time.UTC)
someDate := time.Date(2024, time.March, 18, 0, 0, 0, 0, time.UTC)
testingDate := time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)
someBinary := []byte{0x01, 0x02, 0x03}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use just 'a', 'b', but your version is also fine :)

binArr[i] = someBinary
}
dbt.mustExec(fmt.Sprintf("insert into %v values (?, ?, ?, ?, ?, ?, ?, ?)", arrayInsertTable), Array(&intArr), Array(&strArr), Array(&ltzArr, TimestampLTZType), Array(&tzArr, TimestampTZType), Array(&ntzArr, TimestampNTZType), Array(&dateArr, DateType), Array(&timeArr, TimeType), Array(&binArr))
dbt.mustExec("ALTER SESSION SET CLIENT_STAGE_ARRAY_BINDING_THRESHOLD = 1")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work? I thought this was an internal parameter.

t.Fatal(err)
}

assertEqualE(t, i, bi)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all values are empty/zeros this comparison succeeds. Maybe it would be better to compare with given values?

interfaceArrayTable := "Snow1313648stageInterface"

runDBTest(t, func(dbt *DBTest) {
dbt.mustExec(fmt.Sprintf("create or replace table %v (c1 integer, c2 string, c3 timestamp_ltz, c4 timestamp_tz, c5 timestamp_ntz, c6 date, c7 time, c8 binary)", arrayInsertTable))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good practice (I know that missing in many tests) to defer dropping the table.

testingDate := time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)
someBinary := []byte{0x01, 0x02, 0x03}

numRows := 5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if such a small number is good enough. There may be a lot of problems with greater number (like 100k) that do not exist with 5 rows. Let's try to increase it and decide if it is not too slow.


func convertTimeToTimeStamp(x time.Time, t snowflakeType) string {
unixTime, _ := new(big.Int).SetString(fmt.Sprintf("%d", x.Unix()), 10)
m, _ := new(big.Int).SetString(strconv.FormatInt(1e9, 10), 10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should propagate the errors here?

tmNanos, _ := new(big.Int).SetString(fmt.Sprintf("%d", x.Nanosecond()), 10)
if t == timestampTzType {
_, offset := x.Zone()
return fmt.Sprintf("%v %v", unixTime.Add(unixTime, tmNanos), offset/60+1440)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously it operated on original time (x in this context), is it intentional to use unixTime here? Your change seems rational to me, but wanted to double check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants