Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cpp/Enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,9 @@ namespace
static_assert((int) ::arrow::Type::type::BINARY == 14);
static_assert((int) ::arrow::Type::type::LARGE_BINARY == 35);
static_assert((int) ::arrow::Type::type::BINARY_VIEW == 40);

static_assert((int) ::arrow::Type::type::LIST == 25);
static_assert((int) ::arrow::Type::type::LARGE_LIST == 36);
static_assert((int) ::arrow::Type::type::LIST_VIEW == 41);
}
}
20 changes: 20 additions & 0 deletions cpp/arrow/ArrowReaderProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,24 @@ extern "C"
{
TRYCATCH(properties->set_binary_type(value);)
}

PARQUETSHARP_EXPORT ExceptionInfo* ArrowReaderProperties_ListType(ArrowReaderProperties* properties, ::arrow::Type::type* value)
{
TRYCATCH(*value = properties->list_type();)
}

PARQUETSHARP_EXPORT ExceptionInfo* ArrowReaderProperties_SetListType(ArrowReaderProperties* properties, ::arrow::Type::type value)
{
TRYCATCH(properties->set_list_type(value);)
}

PARQUETSHARP_EXPORT ExceptionInfo* ArrowReaderProperties_GetArrowExtensionEnabled(ArrowReaderProperties* properties, bool* extensions_enabled)
{
TRYCATCH(*extensions_enabled = properties->get_arrow_extensions_enabled();)
}

PARQUETSHARP_EXPORT ExceptionInfo* ArrowReaderProperties_SetArrowExtensionEnabled(ArrowReaderProperties* properties, bool extensions_enabled)
{
TRYCATCH(properties->set_arrow_extensions_enabled(extensions_enabled);)
}
}
7 changes: 7 additions & 0 deletions csharp.test/Arrow/TestArrowReaderProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public void TestDefaultProperties()
Assert.That(properties.GetReadDictionary(0), Is.False);
Assert.That(properties.PreBuffer, Is.True);
Assert.That(properties.CoerceInt96TimestampUnit, Is.EqualTo(Apache.Arrow.Types.TimeUnit.Nanosecond));
Assert.That(properties.BinaryType, Is.EqualTo(Apache.Arrow.Types.ArrowTypeId.Binary));
Assert.That(properties.ListType, Is.EqualTo(Apache.Arrow.Types.ArrowTypeId.List));
Assert.That(properties.ArrowExtensionEnabled, Is.False);
}

[Test]
Expand All @@ -29,13 +32,17 @@ public void TestSetProperties()
properties.PreBuffer = false;
properties.CoerceInt96TimestampUnit = Apache.Arrow.Types.TimeUnit.Microsecond;
properties.BinaryType = Apache.Arrow.Types.ArrowTypeId.LargeBinary;
properties.ListType = Apache.Arrow.Types.ArrowTypeId.LargeList;
properties.ArrowExtensionEnabled = true;

Assert.That(properties.UseThreads, Is.True);
Assert.That(properties.BatchSize, Is.EqualTo(789));
Assert.That(properties.GetReadDictionary(0), Is.True);
Assert.That(properties.PreBuffer, Is.False);
Assert.That(properties.CoerceInt96TimestampUnit, Is.EqualTo(Apache.Arrow.Types.TimeUnit.Microsecond));
Assert.That(properties.BinaryType, Is.EqualTo(Apache.Arrow.Types.ArrowTypeId.LargeBinary));
Assert.That(properties.ListType, Is.EqualTo(Apache.Arrow.Types.ArrowTypeId.LargeList));
Assert.That(properties.ArrowExtensionEnabled, Is.True);
}
}
}
50 changes: 50 additions & 0 deletions csharp/Arrow/ArrowReaderProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,44 @@ public Apache.Arrow.Types.ArrowTypeId BinaryType
}
}

/// <summary>
/// The Arrow list type to read Parquet list columns as.
///
/// Allowed values are ArrowTypeId.List, ArrowTypeId.LargeList and ArrowTypeId.ListView.
/// Default is ArrowTypeId.List.
///
/// If a serialized Arrow schema is found in the Parquet metadata,
/// this setting is ignored and the Arrow schema takes precedence
/// </summary>
public Apache.Arrow.Types.ArrowTypeId ListType
{
get
{
ParquetSharp.CppTypeId value = ExceptionInfo.Return<ParquetSharp.CppTypeId>(Handle, ArrowReaderProperties_ListType);
return value.toPublicEnum();
}
set
{
ParquetSharp.CppTypeId cppValue = value.toCppEnum();
ExceptionInfo.Check(ArrowReaderProperties_SetListType(Handle.IntPtr, cppValue));
GC.KeepAlive(Handle);
}
}

/// <summary>
/// Whether to enable Parquet-supported Arrow extension types.
/// Default is false.
/// </summary>
public bool ArrowExtensionEnabled
{
get => ExceptionInfo.Return<bool>(Handle, ArrowReaderProperties_GetArrowExtensionEnabled);
set
{
ExceptionInfo.Check(ArrowReaderProperties_SetArrowExtensionEnabled(Handle.IntPtr, value));
GC.KeepAlive(Handle);
}
}

[DllImport(ParquetDll.Name)]
private static extern IntPtr ArrowReaderProperties_GetDefault(out IntPtr readerProperties);

Expand Down Expand Up @@ -175,6 +213,18 @@ public Apache.Arrow.Types.ArrowTypeId BinaryType
[DllImport(ParquetDll.Name)]
private static extern IntPtr ArrowReaderProperties_SetBinaryType(IntPtr readerProperties, ParquetSharp.CppTypeId value);

[DllImport(ParquetDll.Name)]
private static extern IntPtr ArrowReaderProperties_ListType(IntPtr readerProperties, out ParquetSharp.CppTypeId value);

[DllImport(ParquetDll.Name)]
private static extern IntPtr ArrowReaderProperties_SetListType(IntPtr readerProperties, ParquetSharp.CppTypeId value);

[DllImport(ParquetDll.Name)]
private static extern IntPtr ArrowReaderProperties_GetArrowExtensionEnabled(IntPtr readerProperties, out bool extensionsEnabled);

[DllImport(ParquetDll.Name)]
private static extern IntPtr ArrowReaderProperties_SetArrowExtensionEnabled(IntPtr readerProperties, bool extensionsEnabled);

internal readonly ParquetHandle Handle;
}
}
3 changes: 3 additions & 0 deletions csharp/ArrowTypeIdExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ internal static class ArrowTypeIdExtensions
Apache.Arrow.Types.ArrowTypeId.Binary => ParquetSharp.CppTypeId.Binary,
Apache.Arrow.Types.ArrowTypeId.LargeBinary => ParquetSharp.CppTypeId.LargeBinary,
Apache.Arrow.Types.ArrowTypeId.BinaryView => ParquetSharp.CppTypeId.BinaryView,
Apache.Arrow.Types.ArrowTypeId.List => ParquetSharp.CppTypeId.List,
Apache.Arrow.Types.ArrowTypeId.LargeList => ParquetSharp.CppTypeId.LargeList,
Apache.Arrow.Types.ArrowTypeId.ListView => ParquetSharp.CppTypeId.ListView,
_ => throw new ArgumentOutOfRangeException(nameof(arrowTypeId), arrowTypeId, null)
};
}
Expand Down
6 changes: 6 additions & 0 deletions csharp/CppTypeId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ internal enum CppTypeId
Binary = 14,
LargeBinary = 35,
BinaryView = 40,
List = 25,
LargeList = 36,
ListView = 41
}

internal static class CppTypeIdExtensions
Expand All @@ -17,6 +20,9 @@ internal static class CppTypeIdExtensions
CppTypeId.Binary => Apache.Arrow.Types.ArrowTypeId.Binary,
CppTypeId.LargeBinary => Apache.Arrow.Types.ArrowTypeId.LargeBinary,
CppTypeId.BinaryView => Apache.Arrow.Types.ArrowTypeId.BinaryView,
CppTypeId.List => Apache.Arrow.Types.ArrowTypeId.List,
CppTypeId.LargeList => Apache.Arrow.Types.ArrowTypeId.LargeList,
CppTypeId.ListView => Apache.Arrow.Types.ArrowTypeId.ListView,
_ => throw new ArgumentOutOfRangeException(nameof(binaryType), binaryType, null)
};
}
Expand Down
4 changes: 4 additions & 0 deletions csharp/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#nullable enable
ParquetSharp.Arrow.ArrowReaderProperties.ArrowExtensionEnabled.get -> bool
ParquetSharp.Arrow.ArrowReaderProperties.ArrowExtensionEnabled.set -> void
ParquetSharp.Arrow.ArrowReaderProperties.BinaryType.get -> Apache.Arrow.Types.ArrowTypeId
ParquetSharp.Arrow.ArrowReaderProperties.BinaryType.set -> void
ParquetSharp.Arrow.ArrowReaderProperties.ListType.get -> Apache.Arrow.Types.ArrowTypeId
ParquetSharp.Arrow.ArrowReaderProperties.ListType.set -> void
ParquetSharp.ReaderProperties.ThriftStringSizeLimit.get -> int
ParquetSharp.ReaderProperties.SetThriftStringSizeLimit(int size) -> void
ParquetSharp.ReaderProperties.ThriftContainerSizeLimit.get -> int
Expand Down