Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.google.errorprone.annotations.ThreadSafe;
import io.trino.operator.table.ExcludeColumns.ExcludeColumnsFunctionHandle;
import io.trino.operator.table.Sequence.SequenceFunctionHandle;
import io.trino.operator.table.json.JsonTable.JsonTableFunctionHandle;
import io.trino.spi.TrinoException;
import io.trino.spi.function.AggregationFunctionMetadata;
import io.trino.spi.function.AggregationImplementation;
import io.trino.spi.function.BoundSignature;
Expand Down Expand Up @@ -51,6 +53,7 @@
import static io.trino.metadata.OperatorNameUtil.unmangleOperator;
import static io.trino.operator.table.ExcludeColumns.getExcludeColumnsFunctionProcessorProvider;
import static io.trino.operator.table.Sequence.getSequenceFunctionProcessorProvider;
import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED;
import static io.trino.spi.function.FunctionKind.AGGREGATE;
import static io.trino.spi.type.BigintType.BIGINT;
import static io.trino.spi.type.BooleanType.BOOLEAN;
Expand Down Expand Up @@ -186,6 +189,9 @@ public TableFunctionProcessorProvider getTableFunctionProcessorProvider(Connecto
if (functionHandle instanceof SequenceFunctionHandle) {
return getSequenceFunctionProcessorProvider();
}
if (functionHandle instanceof JsonTableFunctionHandle) {
throw new TrinoException(NOT_SUPPORTED, "Json_table is not yet supported");
}

return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.operator.table.json;

import io.trino.spi.function.table.ConnectorTableFunctionHandle;
import io.trino.spi.type.Type;

import static java.util.Objects.requireNonNull;

public class JsonTable
{
/**
* This class comprises all information necessary to execute the json_table function:
*
* @param processingPlan the root of the processing plan tree
* @param outer the parent-child relationship between the input relation and the processingPlan result
* @param errorOnError the error behavior: true for ERROR ON ERROR, false for EMPTY ON ERROR
* @param parametersRowType type of the row containing JSON path parameters for the root JSON path. The function expects the parameters row in the channel 1.
* Other channels in the input page correspond to JSON context item (channel 0), and default values for the value columns. Each value column in the processingPlan
* knows the indexes of its default channels.
* @param outputTypes types of the proper columns produced by the function
*/
public record JsonTableFunctionHandle(JsonTablePlanNode processingPlan, boolean outer, boolean errorOnError, Type parametersRowType, Type[] outputTypes)
implements ConnectorTableFunctionHandle
{
public JsonTableFunctionHandle
{
requireNonNull(processingPlan, "processingPlan is null");
requireNonNull(parametersRowType, "parametersRowType is null");
requireNonNull(outputTypes, "outputTypes is null");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.operator.table.json;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
property = "@type")
@JsonSubTypes({
@JsonSubTypes.Type(value = JsonTableOrdinalityColumn.class, name = "ordinality"),
@JsonSubTypes.Type(value = JsonTableQueryColumn.class, name = "query"),
@JsonSubTypes.Type(value = JsonTableValueColumn.class, name = "value"),
})

public sealed interface JsonTableColumn
permits JsonTableOrdinalityColumn, JsonTableQueryColumn, JsonTableValueColumn
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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.operator.table.json;

public record JsonTableOrdinalityColumn(int outputIndex)
implements JsonTableColumn
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.operator.table.json;

import com.google.common.collect.ImmutableList;

import java.util.List;

import static com.google.common.base.Preconditions.checkArgument;

public record JsonTablePlanCross(List<JsonTablePlanNode> siblings)
implements JsonTablePlanNode
{
public JsonTablePlanCross(List<JsonTablePlanNode> siblings)
{
this.siblings = ImmutableList.copyOf(siblings);
checkArgument(siblings.size() >= 2, "less than 2 siblings in Cross node");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.operator.table.json;

import com.google.common.collect.ImmutableList;
import io.trino.json.ir.IrJsonPath;

import java.util.List;

import static java.util.Objects.requireNonNull;

public record JsonTablePlanLeaf(IrJsonPath path, List<JsonTableColumn> columns)
implements JsonTablePlanNode
{
public JsonTablePlanLeaf(IrJsonPath path, List<JsonTableColumn> columns)
{
this.path = requireNonNull(path, "path is null");
this.columns = ImmutableList.copyOf(columns);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.operator.table.json;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
property = "@type")
@JsonSubTypes({
@JsonSubTypes.Type(value = JsonTablePlanCross.class, name = "cross"),
@JsonSubTypes.Type(value = JsonTablePlanLeaf.class, name = "leaf"),
@JsonSubTypes.Type(value = JsonTablePlanSingle.class, name = "single"),
@JsonSubTypes.Type(value = JsonTablePlanUnion.class, name = "union"),
})

public sealed interface JsonTablePlanNode
permits JsonTablePlanCross, JsonTablePlanLeaf, JsonTablePlanSingle, JsonTablePlanUnion
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.operator.table.json;

import com.google.common.collect.ImmutableList;
import io.trino.json.ir.IrJsonPath;

import java.util.List;

import static java.util.Objects.requireNonNull;

public record JsonTablePlanSingle(IrJsonPath path, List<JsonTableColumn> columns, boolean outer, JsonTablePlanNode child)
implements JsonTablePlanNode
{
public JsonTablePlanSingle(IrJsonPath path, List<JsonTableColumn> columns, boolean outer, JsonTablePlanNode child)
{
this.path = requireNonNull(path, "path is null");
this.columns = ImmutableList.copyOf(columns);
this.outer = outer;
this.child = requireNonNull(child, "child is null");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.operator.table.json;

import com.google.common.collect.ImmutableList;

import java.util.List;

import static com.google.common.base.Preconditions.checkArgument;

public record JsonTablePlanUnion(List<JsonTablePlanNode> siblings)
implements JsonTablePlanNode
{
public JsonTablePlanUnion(List<JsonTablePlanNode> siblings)
{
this.siblings = ImmutableList.copyOf(siblings);
checkArgument(siblings.size() >= 2, "less than 2 siblings in Union node");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.operator.table.json;

import io.trino.json.ir.IrJsonPath;
import io.trino.metadata.ResolvedFunction;

import static java.util.Objects.requireNonNull;

/**
* This representation does not contain all properties of the column as specified in json_table invocation.
* Certain properties are handled by the output function which is applied later.
* These are: output format and quotes behavior.
*/
public record JsonTableQueryColumn(
int outputIndex,
ResolvedFunction function,
IrJsonPath path,
long wrapperBehavior,
long emptyBehavior,
long errorBehavior)
implements JsonTableColumn
{
public JsonTableQueryColumn
{
requireNonNull(function, "function is null");
requireNonNull(path, "path is null");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.operator.table.json;

import io.trino.json.ir.IrJsonPath;
import io.trino.metadata.ResolvedFunction;

import static java.util.Objects.requireNonNull;

public record JsonTableValueColumn(
int outputIndex,
ResolvedFunction function,
IrJsonPath path,
long emptyBehavior,
int emptyDefaultInput, // channel number or -1 when default not specified
long errorBehavior,
int errorDefaultInput) // channel number or -1 when default not specified
implements JsonTableColumn
{
public JsonTableValueColumn
{
requireNonNull(function, "function is null");
requireNonNull(path, "path is null");
}
}
Loading