Skip to content

Commit cee17a3

Browse files
committed
Test with -08:30 and 11:00 timezone
1 parent bd12287 commit cee17a3

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

arrow/extensions/timestamp_with_offset_test.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import (
3434

3535
var testTimeUnit = arrow.Microsecond
3636

37-
var testDate1 = time.Date(2025, 01, 01, 00, 00, 00, 00, time.FixedZone("UTC+00:00", 0))
37+
var testDate0 = time.Date(2025, 01, 01, 00, 00, 00, 00, time.FixedZone("UTC+00:00", 0))
3838

39-
var testZone1 = time.FixedZone("UTC-08:00", -8*60*60)
40-
var testDate2 = testDate1.In(testZone1)
39+
var testZone1 = time.FixedZone("UTC-08:30", -8*60*60 -30*60)
40+
var testDate1 = testDate0.In(testZone1)
4141

42-
var testZone2 = time.FixedZone("UTC+06:00", +6*60*60)
43-
var testDate3 = testDate1.In(testZone2)
42+
var testZone2 = time.FixedZone("UTC+11:00", +11*60*60)
43+
var testDate2 = testDate0.In(testZone2)
4444

4545
func dict(index arrow.DataType) arrow.DataType {
4646
return &arrow.DictionaryType{
@@ -201,20 +201,20 @@ func TestTimestampWithOffsetExtensionBuilder(t *testing.T) {
201201
// use that encoding (there is no way to pass a flag to array.FromJSON to say explicitly what storage type you want)
202202
primitiveBuilder, err := extensions.NewTimestampWithOffsetBuilder(mem, testTimeUnit, arrow.PrimitiveTypes.Int16)
203203
assert.NoError(t, err)
204-
primitiveBuilder.Append(testDate1)
204+
primitiveBuilder.Append(testDate0)
205205
primitiveBuilder.AppendNull()
206+
primitiveBuilder.Append(testDate1)
206207
primitiveBuilder.Append(testDate2)
207-
primitiveBuilder.Append(testDate3)
208208
jsonComparisonArr := primitiveBuilder.NewArray()
209209
defer jsonComparisonArr.Release()
210210

211211
for _, offsetType := range allAllowedOffsetTypes {
212212
builder, _ := extensions.NewTimestampWithOffsetBuilder(mem, testTimeUnit, offsetType)
213213

214-
builder.Append(testDate1)
214+
builder.Append(testDate0)
215215
builder.AppendNull()
216+
builder.Append(testDate1)
216217
builder.Append(testDate2)
217-
builder.Append(testDate3)
218218

219219
// it should build the array with the correct size
220220
arr := builder.NewArray()
@@ -223,9 +223,9 @@ func TestTimestampWithOffsetExtensionBuilder(t *testing.T) {
223223
defer arr.Release()
224224

225225
// typedArr.Value(i) should return values adjusted for their original timezone
226-
assert.Equal(t, testDate1, typedArr.Value(0))
227-
assert.Equal(t, testDate2, typedArr.Value(2))
228-
assert.Equal(t, testDate3, typedArr.Value(3))
226+
assert.Equal(t, testDate0, typedArr.Value(0))
227+
assert.Equal(t, testDate1, typedArr.Value(2))
228+
assert.Equal(t, testDate2, typedArr.Value(3))
229229

230230
// storage TimeUnit should be the same as we pass in to the builder, and storage timezone should be UTC
231231
timestampStructField := typedArr.Storage().(*array.Struct).Field(0)
@@ -235,13 +235,13 @@ func TestTimestampWithOffsetExtensionBuilder(t *testing.T) {
235235

236236
// stored values should be equivalent to the raw values in UTC
237237
timestampsArr := timestampStructField.(*array.Timestamp)
238-
assert.Equal(t, testDate1.In(time.UTC), timestampsArr.Value(0).ToTime(testTimeUnit))
239-
assert.Equal(t, testDate2.In(time.UTC), timestampsArr.Value(2).ToTime(testTimeUnit))
240-
assert.Equal(t, testDate3.In(time.UTC), timestampsArr.Value(3).ToTime(testTimeUnit))
238+
assert.Equal(t, testDate0.In(time.UTC), timestampsArr.Value(0).ToTime(testTimeUnit))
239+
assert.Equal(t, testDate1.In(time.UTC), timestampsArr.Value(2).ToTime(testTimeUnit))
240+
assert.Equal(t, testDate2.In(time.UTC), timestampsArr.Value(3).ToTime(testTimeUnit))
241241

242242
// the array should encode itself as JSON and string
243243
arrStr := arr.String()
244-
assert.Equal(t, fmt.Sprintf(`["%[1]s" (null) "%[2]s" "%[3]s"]`, testDate1, testDate2, testDate3), arrStr)
244+
assert.Equal(t, fmt.Sprintf(`["%[1]s" (null) "%[2]s" "%[3]s"]`, testDate0, testDate1, testDate2), arrStr)
245245
jsonStr, err := json.Marshal(arr)
246246
assert.NoError(t, err)
247247

@@ -270,23 +270,23 @@ func TestTimestampWithOffsetExtensionRecordBuilder(t *testing.T) {
270270
fieldBuilder := builder.Field(0).(*extensions.TimestampWithOffsetBuilder)
271271

272272
// append a simple time.Time
273-
fieldBuilder.Append(testDate1)
273+
fieldBuilder.Append(testDate0)
274274

275275
// append a null and 2 time.Time all at once
276276
values := []time.Time{
277277
time.Unix(0, 0).In(time.UTC),
278+
testDate1,
278279
testDate2,
279-
testDate3,
280280
}
281281
valids := []bool{false, true, true}
282282
fieldBuilder.AppendValues(values, valids)
283283

284284
// append a value from RFC3339 string
285-
fieldBuilder.AppendValueFromString(testDate1.Format(time.RFC3339))
285+
fieldBuilder.AppendValueFromString(testDate0.Format(time.RFC3339))
286286

287287
// append value formatted in a different string layout
288288
fieldBuilder.Layout = time.RFC3339Nano
289-
fieldBuilder.AppendValueFromString(testDate2.Format(time.RFC3339Nano))
289+
fieldBuilder.AppendValueFromString(testDate1.Format(time.RFC3339Nano))
290290

291291
record := builder.NewRecordBatch()
292292

@@ -295,10 +295,10 @@ func TestTimestampWithOffsetExtensionRecordBuilder(t *testing.T) {
295295
require.NoError(t, err)
296296
expect := `[{"timestamp_with_offset":"2025-01-01T00:00:00Z"}
297297
,{"timestamp_with_offset":null}
298-
,{"timestamp_with_offset":"2024-12-31T16:00:00-08:00"}
299-
,{"timestamp_with_offset":"2025-01-01T06:00:00+06:00"}
298+
,{"timestamp_with_offset":"2024-12-31T15:30:00-08:30"}
299+
,{"timestamp_with_offset":"2025-01-01T11:00:00+11:00"}
300300
,{"timestamp_with_offset":"2025-01-01T00:00:00Z"}
301-
,{"timestamp_with_offset":"2024-12-31T16:00:00-08:00"}
301+
,{"timestamp_with_offset":"2024-12-31T15:30:00-08:30"}
302302
]`
303303
require.Equal(t, expect, string(json))
304304

@@ -317,10 +317,10 @@ func TestTimestampWithOffsetTypeBatchIPCRoundTrip(t *testing.T) {
317317

318318
for _, offsetType := range allAllowedOffsetTypes {
319319
builder, _ := extensions.NewTimestampWithOffsetBuilder(mem, testTimeUnit, offsetType)
320-
builder.Append(testDate1)
320+
builder.Append(testDate0)
321321
builder.AppendNull()
322+
builder.Append(testDate1)
322323
builder.Append(testDate2)
323-
builder.Append(testDate3)
324324
arr := builder.NewArray()
325325
defer arr.Release()
326326

0 commit comments

Comments
 (0)