Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native Trino Ion Format Integration #24511

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions lib/trino-hive-formats/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
</properties>

<dependencies>

<dependency>
<groupId>com.amazon.ion</groupId>
<artifactId>ion-java</artifactId>
<version>${dep.ion.version}</version>
</dependency>

<dependency>
<groupId>com.amazon.ion</groupId>
<artifactId>ion-java-path-extraction</artifactId>
<version>${dep.ion-path-extraction.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public final class HiveClassNames
public static final String HUDI_PARQUET_REALTIME_INPUT_FORMAT = "org.apache.hudi.hadoop.realtime.HoodieParquetRealtimeInputFormat";
public static final String HUDI_INPUT_FORMAT = "com.uber.hoodie.hadoop.HoodieInputFormat";
public static final String HUDI_REALTIME_INPUT_FORMAT = "com.uber.hoodie.hadoop.realtime.HoodieRealtimeInputFormat";
public static final String ION_SERDE_CLASS = "com.amazon.ionhiveserde.IonHiveSerDe";
public static final String ION_INPUT_FORMAT = "com.amazon.ionhiveserde.formats.IonInputFormat";
public static final String ION_OUTPUT_FORMAT = "com.amazon.ionhiveserde.formats.IonOutputFormat";
public static final String JSON_SERDE_CLASS = "org.apache.hive.hcatalog.data.JsonSerDe";
public static final String LEGACY_JSON_SERDE_CLASS = "org.apache.hadoop.hive.serde2.JsonSerDe";
public static final String OPENX_JSON_SERDE_CLASS = "org.openx.data.jsonserde.JsonSerDe";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.hive.formats.ion;

import com.amazon.ion.IonException;
import com.amazon.ion.IonReader;

public interface IonDecoder
{
/**
* Reads the _current_ top-level-value from the IonReader.
* <p>
* Expects that the calling code has called IonReader.next()
* to position the reader at the value to be decoded.
*/
void decode(IonReader reader)
throws IonException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.hive.formats.ion;

import java.util.Map;

/**
* Captures the SerDe properties that affect decoding.
*
* @param pathExtractors Map of column name => ion paths
* for each entry in the map, the value bound to the column will be the result
* of extracting the given search path.
* @param strictTyping whether the path extractions should enforce type expectations.
* this only affects type checking of path extractions; any value decoded into
* a trino column will be correctly typed or coerced for that column.
* @param caseSensitive whether field name matching should be case-sensitive or not.
*/
public record IonDecoderConfig(Map<String, String> pathExtractors, Boolean strictTyping, Boolean caseSensitive)
{
static IonDecoderConfig defaultConfig()
{
return new IonDecoderConfig(Map.of(), false, false);
}

IonDecoderConfig withStrictTyping()
{
return new IonDecoderConfig(pathExtractors, true, caseSensitive);
}

IonDecoderConfig withCaseSensitive()
{
return new IonDecoderConfig(pathExtractors, strictTyping, true);
}

IonDecoderConfig withPathExtractors(Map<String, String> pathExtractors)
{
return new IonDecoderConfig(pathExtractors, strictTyping, caseSensitive);
}
}
Loading
Loading