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
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@
<module>presto-hana</module>
<module>presto-openapi</module>
<module>presto-native-sidecar-plugin</module>
<module>presto-common-arrow</module>
<module>presto-base-arrow-flight</module>
<module>presto-function-server</module>
<module>presto-router-example-plugin-scheduler</module>
<module>presto-plan-checker-router-plugin</module>
<module>presto-sql-helpers/presto-sql-invoked-functions-plugin</module>
<module>presto-sql-helpers/presto-native-sql-invoked-functions-plugin</module>
<module>presto-lance</module>
</modules>

<dependencyManagement>
Expand Down Expand Up @@ -1010,6 +1012,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-common-arrow</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-base-arrow-flight</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions presto-base-arrow-flight/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-common-arrow</artifactId>
</dependency>

<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-memory-core</artifactId>
Expand Down Expand Up @@ -250,6 +255,7 @@
<ignoredNonTestScopedDependency>com.fasterxml.jackson.core:jackson-databind</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>com.facebook.airlift:log-manager</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>javax.inject:javax.inject</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>io.airlift:slice</ignoredNonTestScopedDependency>
</ignoredNonTestScopedDependencies>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public TestingArrowBlockBuilder(TypeManager typeManager)
}

@Override
protected Type getPrestoTypeFromArrowField(Field field)
public Type getPrestoTypeFromArrowField(Field field)
{
String columnLength = field.getMetadata().get("columnLength");
int length = columnLength != null ? Integer.parseInt(columnLength) : 0;
Expand Down
87 changes: 87 additions & 0 deletions presto-common-arrow/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-root</artifactId>
<version>0.297-SNAPSHOT</version>
</parent>

<artifactId>presto-common-arrow</artifactId>
<name>presto-common-arrow</name>
<description>Presto - Common Arrow Utilities</description>

<properties>
<air.main.basedir>${project.parent.basedir}</air.main.basedir>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-vector</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-spi</artifactId>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-common</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>slice</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<ignoredClassPatterns>
<ignoredClassPattern>module-info</ignoredClassPattern>
<ignoredClassPattern>META-INF.versions.9.module-info</ignoredClassPattern>
</ignoredClassPatterns>
<ignoredResourcePatterns>
<ignoredResourcePattern>arrow-git.properties</ignoredResourcePattern>
<ignoredResourcePattern>about.html</ignoredResourcePattern>
</ignoredResourcePatterns>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.apache.arrow.vector.TimeMicroVector;
import org.apache.arrow.vector.TimeMilliVector;
import org.apache.arrow.vector.TimeSecVector;
import org.apache.arrow.vector.TimeStampMicroTZVector;
import org.apache.arrow.vector.TimeStampMicroVector;
import org.apache.arrow.vector.TimeStampMilliTZVector;
import org.apache.arrow.vector.TimeStampMilliVector;
Expand All @@ -62,6 +63,7 @@
import org.apache.arrow.vector.ValueVector;
import org.apache.arrow.vector.VarBinaryVector;
import org.apache.arrow.vector.VarCharVector;
import org.apache.arrow.vector.complex.FixedSizeListVector;
import org.apache.arrow.vector.complex.ListVector;
import org.apache.arrow.vector.complex.MapVector;
import org.apache.arrow.vector.complex.StructVector;
Expand Down Expand Up @@ -112,7 +114,7 @@ public Block buildBlockFromFieldVector(FieldVector vector, Type type, Dictionary
return builder.build();
}

protected Type getPrestoTypeFromArrowField(Field field)
public Type getPrestoTypeFromArrowField(Field field)
{
switch (field.getType().getTypeID()) {
case Int:
Expand All @@ -139,7 +141,8 @@ protected Type getPrestoTypeFromArrowField(Field field)
return BooleanType.BOOLEAN;
case Time:
return TimeType.TIME;
case List: {
case List:
case FixedSizeList: {
List<Field> children = field.getChildren();
checkArgument(children.size() == 1, "Arrow List expected to have 1 child Field, got: " + children.size());
return new ArrayType(getPrestoTypeFromArrowField(field.getChildren().get(0)));
Expand Down Expand Up @@ -292,13 +295,19 @@ else if (vector instanceof TimeStampSecVector) {
else if (vector instanceof TimeMicroVector) {
assignBlockFromTimeMicroVector((TimeMicroVector) vector, type, builder, startIndex, endIndex);
}
else if (vector instanceof TimeStampMicroTZVector) {
assignBlockFromTimeStampMicroTZVector((TimeStampMicroTZVector) vector, type, builder, startIndex, endIndex);
}
else if (vector instanceof TimeStampMilliTZVector) {
assignBlockFromTimeMilliTZVector((TimeStampMilliTZVector) vector, type, builder, startIndex, endIndex);
}
else if (vector instanceof MapVector) {
// NOTE: MapVector is also instanceof ListVector, so check for Map first
assignBlockFromMapVector((MapVector) vector, type, builder, startIndex, endIndex);
}
else if (vector instanceof FixedSizeListVector) {
assignBlockFromFixedSizeListVector((FixedSizeListVector) vector, type, builder, startIndex, endIndex);
}
else if (vector instanceof ListVector) {
assignBlockFromListVector((ListVector) vector, type, builder, startIndex, endIndex);
}
Expand Down Expand Up @@ -666,6 +675,49 @@ public void assignBlockFromListVector(ListVector vector, Type type, BlockBuilder
}
}

public void assignBlockFromFixedSizeListVector(FixedSizeListVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
{
if (!(type instanceof ArrayType)) {
throw new IllegalArgumentException("Type must be an ArrayType for FixedSizeListVector");
}

ArrayType arrayType = (ArrayType) type;
Type elementType = arrayType.getElementType();
int listSize = vector.getListSize();

for (int i = startIndex; i < endIndex; i++) {
if (vector.isNull(i)) {
builder.appendNull();
}
else {
BlockBuilder elementBuilder = builder.beginBlockEntry();
int elementStart = i * listSize;
int elementEnd = elementStart + listSize;
assignBlockFromValueVector(
vector.getDataVector(), elementType, elementBuilder, elementStart, elementEnd);
builder.closeEntry();
}
}
}

public void assignBlockFromTimeStampMicroTZVector(TimeStampMicroTZVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
{
if (!(type instanceof TimestampType)) {
throw new IllegalArgumentException("Expected TimestampType but got " + type.getClass().getName());
}

for (int i = startIndex; i < endIndex; i++) {
if (vector.isNull(i)) {
builder.appendNull();
}
else {
long micros = vector.get(i);
long millis = TimeUnit.MICROSECONDS.toMillis(micros);
type.writeLong(builder, millis);
}
}
}

public void assignBlockFromMapVector(MapVector vector, Type type, BlockBuilder builder, int startIndex, int endIndex)
{
if (!(type instanceof MapType)) {
Expand Down
1 change: 1 addition & 0 deletions presto-docs/src/main/sphinx/connector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ from different data sources.
connector/kafka
connector/kafka-tutorial
connector/kudu
connector/lance
connector/larksheets
connector/localfile
connector/memory
Expand Down
Loading
Loading