Skip to content

Commit

Permalink
add support for IntervalType
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coe committed Sep 24, 2024
1 parent 2fca8e4 commit 4f633b4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
8 changes: 7 additions & 1 deletion csharp/src/Apache.Arrow.Adbc/AdbcStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ public virtual void Dispose()
return uInt32Array.GetValue(index);
case UInt64Array uInt64Array:
return uInt64Array.GetValue(index);

case DayTimeIntervalArray dayTimeIntervalArray:
return dayTimeIntervalArray.GetValue(index);
case MonthDayNanosecondIntervalArray monthDayNanosecondIntervalArray:
return monthDayNanosecondIntervalArray.GetValue(index);
case YearMonthIntervalArray yearMonthIntervalArray:
return yearMonthIntervalArray.GetValue(index);
case BinaryArray binaryArray:
if (!binaryArray.IsNull(index))
return binaryArray.GetBytes(index).ToArray();
Expand All @@ -250,6 +255,7 @@ public virtual void Dispose()

// not covered:
// -- struct array
// -- map array
// -- dictionary array
// -- fixed size binary
// -- list array
Expand Down
12 changes: 12 additions & 0 deletions csharp/src/Client/SchemaConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Data;
using System.Data.Common;
using System.Data.SqlTypes;
using Apache.Arrow.Scalars;
using Apache.Arrow.Types;

namespace Apache.Arrow.Adbc.Client
Expand Down Expand Up @@ -190,6 +191,17 @@ public static Type GetArrowType(Field f, DecimalBehavior decimalBehavior)
case ArrowTypeId.Null:
return typeof(DBNull);

case ArrowTypeId.Interval:
switch (((IntervalType)f.DataType).Unit) {
case IntervalUnit.MonthDayNanosecond:
return typeof(MonthDayNanosecondInterval);
case IntervalUnit.DayTime:
return typeof(DayTimeInterval);
case IntervalUnit.YearMonth:
return typeof(YearMonthInterval);
}
goto default;

default:
return f.DataType.GetType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit" Version="2.9.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
6 changes: 2 additions & 4 deletions csharp/test/Drivers/Interop/FlightSql/FlightSqlData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Text;
using Apache.Arrow.Scalars;
using Apache.Arrow.Types;

namespace Apache.Arrow.Adbc.Tests.Drivers.Interop.FlightSql
Expand Down Expand Up @@ -85,10 +86,7 @@ public static SampleDataBuilder GetSampleData()
new ColumnNetTypeArrowTypeValue("Time", typeof(TimeSpan), typeof(Time64Type), new TimeSpan(12, 34, 56)),
#endif
new ColumnNetTypeArrowTypeValue("Timestamp", typeof(DateTimeOffset), typeof(TimestampType), new DateTimeOffset(new DateTime(2024, 9, 10, 12, 34, 56), TimeSpan.Zero)),

// despite a value specified, this is coming back as null from the client call
new ColumnNetTypeArrowTypeValue("Interval", typeof(IntervalType), typeof(IntervalType), null),

new ColumnNetTypeArrowTypeValue("Interval", typeof(MonthDayNanosecondInterval), typeof(IntervalType), new MonthDayNanosecondInterval(12, 0, 0)),
new ColumnNetTypeArrowTypeValue("JSON", typeof(string), typeof(StringType), "[1, 2, 3]"),
new ColumnNetTypeArrowTypeValue("JSON_Array", typeof(string), typeof(StringType), "[{\"key\": \"value\"}]"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ private void TrySetFlightSqlEnvironment(string? environmentName)
{
if (string.IsNullOrEmpty(environmentName))
return;


}

/// <summary>
Expand Down

0 comments on commit 4f633b4

Please sign in to comment.