Skip to content

Commit b14f498

Browse files
author
David Coe
committed
pin
1 parent d1d06be commit b14f498

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

csharp/src/Apache.Arrow.Adbc/Extensions/IArrowArrayExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ public static class IArrowArrayExtensions
244244
switch (time32Type.Unit)
245245
{
246246
case TimeUnit.Second:
247-
return (array, index) => array.IsNull(index) ? null : TimeSpan.FromSeconds(((Time32Array)array).GetValue(index)!.Value);
247+
return (array, index) => array.IsNull(index) ? null : TimeSpan.FromSeconds(((Time32Array)array).GetSeconds(index)!.Value);
248248
case TimeUnit.Millisecond:
249-
return (array, index) => array.IsNull(index) ? null : TimeSpan.FromMilliseconds(((Time32Array)array).GetValue(index)!.Value);
249+
return (array, index) => array.IsNull(index) ? null : TimeSpan.FromMilliseconds(((Time32Array)array).GetMilliSeconds(index)!.Value);
250250
default:
251251
throw new InvalidDataException("Unsupported time unit for Time32Type");
252252
}
@@ -257,7 +257,7 @@ public static class IArrowArrayExtensions
257257
case TimeUnit.Microsecond:
258258
return (array, index) => array.IsNull(index) ? null : TimeSpan.FromTicks(((Time64Array)array).GetMicroSeconds(index)!.Value * 10);
259259
case TimeUnit.Nanosecond:
260-
return (array, index) => array.IsNull(index) ? null : TimeSpan.FromTicks(((Time64Array)array).GetNanoSeconds(index)!.Value / 100);
260+
return (array, index) => array.IsNull(index) ? null : TimeSpan.FromTicks(((Time64Array)array).GetValue(index)!.Value / 100);
261261
default:
262262
throw new InvalidDataException("Unsupported time unit for Time64Type");
263263
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Linq;
21+
using System.Text;
22+
using System.Threading.Tasks;
23+
using Xunit;
24+
using Apache.Arrow.Adbc.Extensions;
25+
26+
namespace Apache.Arrow.Adbc.Tests
27+
{
28+
public class IArrowArrayExtensionsTests
29+
{
30+
31+
[Fact]
32+
public void ValidateTime32()
33+
{
34+
TimeSpan t = TimeSpan.FromMinutes(5);
35+
int seconds = Convert.ToInt32(t.TotalMinutes * 60);
36+
Time32Array.Builder secondBuilder = new Time32Array.Builder(Types.TimeUnit.Second);
37+
secondBuilder.Append(seconds);
38+
Time32Array t32seconds = secondBuilder.Build();
39+
40+
Assert.Equal(seconds, t32seconds.GetValue(0));
41+
Assert.Equal(seconds, t32seconds.GetSeconds(0));
42+
Assert.Equal(t, t32seconds.ValueAt(0));
43+
Assert.Equal(t, t32seconds.Data.DataType.GetValueConverter().Invoke(t32seconds, 0));
44+
45+
int totalMs = Convert.ToInt32(t.TotalMilliseconds);
46+
Time32Array.Builder msbuilder = new Time32Array.Builder(Types.TimeUnit.Millisecond);
47+
msbuilder.Append(totalMs);
48+
Time32Array t32ms = msbuilder.Build();
49+
50+
Assert.Equal(totalMs, t32ms.GetValue(0));
51+
Assert.Equal(totalMs, t32ms.GetMilliSeconds(0));
52+
Assert.Equal(t, t32ms.ValueAt(0));
53+
Assert.Equal(t, t32ms.Data.DataType.GetValueConverter().Invoke(t32ms, 0));
54+
}
55+
56+
[Fact]
57+
public void ValidateTime64() { }
58+
59+
}
60+
}

csharp/test/Drivers/BigQuery/BigQueryData.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
using System;
1919
using System.Collections.Generic;
2020
using System.Data.SqlTypes;
21-
using System.Dynamic;
2221
using System.Text;
2322
using System.Text.Json;
2423
using Apache.Arrow.Types;

0 commit comments

Comments
 (0)