Skip to content

Commit

Permalink
json-path parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
liugddx committed Nov 22, 2022
1 parent f3be0b1 commit 90d33c1
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntFunction;

/** Tool class used to convert from {@link JsonNode} to {@link org.apache.seatunnel.api.table.type.SeaTunnelRow}. * */
/**
* Tool class used to convert from {@link JsonNode} to {@link org.apache.seatunnel.api.table.type.SeaTunnelRow}. *
*/
public class JsonToRowConverters implements Serializable {

private static final long serialVersionUID = 1L;
Expand All @@ -61,10 +62,14 @@ public class JsonToRowConverters implements Serializable {
.appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true)
.toFormatter();

/** Flag indicating whether to fail if a field is missing. */
/**
* Flag indicating whether to fail if a field is missing.
*/
private final boolean failOnMissingField;

/** Flag indicating whether to ignore invalid fields/rows (default: throw an exception). */
/**
* Flag indicating whether to ignore invalid fields/rows (default: throw an exception).
*/
private final boolean ignoreParseErrors;

public JsonToRowConverters(
Expand All @@ -74,12 +79,16 @@ public JsonToRowConverters(
this.ignoreParseErrors = ignoreParseErrors;
}

/** Creates a runtime converter which is null safe. */
/**
* Creates a runtime converter which is null safe.
*/
public JsonToRowConverter createConverter(SeaTunnelDataType<?> type) {
return wrapIntoNullableConverter(createNotNullConverter(type));
}

/** Creates a runtime converter which assuming input object is not null. */
/**
* Creates a runtime converter which assuming input object is not null.
*/
private JsonToRowConverter createNotNullConverter(SeaTunnelDataType<?> type) {
SqlType sqlType = type.getSqlType();
switch (sqlType) {
Expand Down Expand Up @@ -302,7 +311,9 @@ public interface JsonToRowConverter extends Serializable {
Object convert(JsonNode jsonNode);
}

/** Exception which refers to parse errors in converters. */
/**
* Exception which refers to parse errors in converters.
*/
private static final class JsonParseException extends RuntimeException {
private static final long serialVersionUID = 1L;

Expand Down

0 comments on commit 90d33c1

Please sign in to comment.