com.google.zetasql.resolvedast.ResolvedNodes Maven / Gradle / Ivy
Show all versions of zetasql-client Show documentation
/*
* Copyright 2019 ZetaSQL Authors
*
* 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.
*
*/
// ResolvedNodes.java GENERATED FROM ResolvedNodes.java.template
package com.google.zetasql.resolvedast;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.Descriptors.OneofDescriptor;
import com.google.protobuf.Message;
import com.google.protobuf.ProtocolMessageEnum;
import com.google.zetasql.AnyResolvedNodeProto;
import com.google.zetasql.Constant;
import com.google.zetasql.ConstantRefProto;
import com.google.zetasql.FieldDescriptorRefProto;
import com.google.zetasql.FileDescriptorSetsBuilder;
import com.google.zetasql.Function;
import com.google.zetasql.OneofDescriptorRefProto;
import com.google.zetasql.ResolvedFunctionCallInfo;
import com.google.zetasql.FunctionProtos.ResolvedFunctionCallInfoProto;
import com.google.zetasql.FunctionProtos.FunctionSignatureProto;
import com.google.zetasql.FunctionProtos.TVFSignatureProto;
import com.google.zetasql.FunctionRefProto;
import com.google.zetasql.FunctionSignature;
import com.google.zetasql.ZetaSQLDescriptorPool.ZetaSQLFieldDescriptor;
import com.google.zetasql.ZetaSQLResolvedNodeKind.ResolvedNodeKind;
import com.google.zetasql.ZetaSQLStrings;
import com.google.zetasql.ZetaSQLType.ProtoTypeProto;
import com.google.zetasql.ZetaSQLType.TypeProto;
import com.google.zetasql.Model;
import com.google.zetasql.ModelRefProto;
import com.google.zetasql.Procedure;
import com.google.zetasql.ProcedureRefProto;
import com.google.zetasql.ResolvedColumnProto;
import com.google.zetasql.ResolvedNodeProto;
import com.google.zetasql.Table;
import com.google.zetasql.TableRefProto;
import com.google.zetasql.TableValuedFunction;
import com.google.zetasql.TableValuedFunctionRefProto;
import com.google.zetasql.TVFSignature;
import com.google.zetasql.Type;
import com.google.zetasql.TypeAnnotationProto.FieldFormat;
import com.google.zetasql.Value;
import com.google.zetasql.ValueWithTypeProto;
import com.google.zetasql.resolvedast.ResolvedColumn;
import com.google.zetasql.resolvedast.ResolvedAggregateHavingModifierEnums.HavingModifierKind;
import com.google.zetasql.resolvedast.ResolvedOrderByItemEnums.NullOrderMode;
import com.google.zetasql.resolvedast.ResolvedStatementEnums.ObjectAccess;
import com.google.zetasql.resolvedast.ResolvedMergeWhenEnums.MatchType;
import com.google.zetasql.resolvedast.ResolvedMergeWhenEnums.ActionType;
import com.google.zetasql.resolvedast.ResolvedWindowFrameEnums.FrameUnit;
import com.google.zetasql.resolvedast.ResolvedInsertStmtEnums.InsertMode;
import com.google.zetasql.resolvedast.ResolvedImportStmtEnums.ImportKind;
import com.google.zetasql.resolvedast.ResolvedWindowFrameExprEnums.BoundaryType;
import com.google.zetasql.resolvedast.ResolvedFunctionCallBaseEnums.ErrorMode;
import com.google.zetasql.resolvedast.ResolvedBeginStmtEnums.ReadWriteMode;
import com.google.zetasql.resolvedast.ResolvedSubqueryExprEnums.SubqueryType;
import com.google.zetasql.resolvedast.ResolvedNonScalarFunctionCallBaseEnums.NullHandlingModifier;
import com.google.zetasql.resolvedast.ResolvedForeignKeyEnums.MatchMode;
import com.google.zetasql.resolvedast.ResolvedForeignKeyEnums.ActionOperation;
import com.google.zetasql.resolvedast.ResolvedArgumentDefEnums.ArgumentKind;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.CreateScope;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.CreateMode;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.SqlSecurity;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.DeterminismLevel;
import com.google.zetasql.resolvedast.ResolvedSampleScanEnums.SampleUnit;
import com.google.zetasql.resolvedast.ResolvedSetOperationScanEnums.SetOperationType;
import com.google.zetasql.resolvedast.ResolvedJoinScanEnums.JoinType;
import com.google.zetasql.ResolvedAbortBatchStmtProto;
import com.google.zetasql.ResolvedAddColumnActionProto;
import com.google.zetasql.ResolvedAggregateFunctionCallProto;
import com.google.zetasql.ResolvedAggregateHavingModifierProto;
import com.google.zetasql.ResolvedAggregateScanProto;
import com.google.zetasql.ResolvedAggregateScanBaseProto;
import com.google.zetasql.AnyResolvedAggregateScanBaseProto;
import com.google.zetasql.ResolvedAlterActionProto;
import com.google.zetasql.AnyResolvedAlterActionProto;
import com.google.zetasql.ResolvedAlterDatabaseStmtProto;
import com.google.zetasql.ResolvedAlterMaterializedViewStmtProto;
import com.google.zetasql.ResolvedAlterObjectStmtProto;
import com.google.zetasql.AnyResolvedAlterObjectStmtProto;
import com.google.zetasql.ResolvedAlterRowAccessPolicyStmtProto;
import com.google.zetasql.ResolvedAlterTableSetOptionsStmtProto;
import com.google.zetasql.ResolvedAlterTableStmtProto;
import com.google.zetasql.ResolvedAlterViewStmtProto;
import com.google.zetasql.ResolvedAnalyticFunctionCallProto;
import com.google.zetasql.ResolvedAnalyticFunctionGroupProto;
import com.google.zetasql.ResolvedAnalyticScanProto;
import com.google.zetasql.ResolvedArgumentProto;
import com.google.zetasql.AnyResolvedArgumentProto;
import com.google.zetasql.ResolvedArgumentDefProto;
import com.google.zetasql.ResolvedArgumentListProto;
import com.google.zetasql.ResolvedArgumentRefProto;
import com.google.zetasql.ResolvedArrayScanProto;
import com.google.zetasql.ResolvedAssertRowsModifiedProto;
import com.google.zetasql.ResolvedAssertStmtProto;
import com.google.zetasql.ResolvedBeginStmtProto;
import com.google.zetasql.ResolvedCallStmtProto;
import com.google.zetasql.ResolvedCastProto;
import com.google.zetasql.ResolvedCheckConstraintProto;
import com.google.zetasql.ResolvedColumnAnnotationsProto;
import com.google.zetasql.ResolvedColumnDefinitionProto;
import com.google.zetasql.ResolvedColumnHolderProto;
import com.google.zetasql.ResolvedColumnRefProto;
import com.google.zetasql.ResolvedCommitStmtProto;
import com.google.zetasql.ResolvedComputedColumnProto;
import com.google.zetasql.ResolvedConstantProto;
import com.google.zetasql.ResolvedCreateConstantStmtProto;
import com.google.zetasql.ResolvedCreateDatabaseStmtProto;
import com.google.zetasql.ResolvedCreateExternalTableStmtProto;
import com.google.zetasql.ResolvedCreateFunctionStmtProto;
import com.google.zetasql.ResolvedCreateIndexStmtProto;
import com.google.zetasql.ResolvedCreateMaterializedViewStmtProto;
import com.google.zetasql.ResolvedCreateModelStmtProto;
import com.google.zetasql.ResolvedCreateProcedureStmtProto;
import com.google.zetasql.ResolvedCreateRowAccessPolicyStmtProto;
import com.google.zetasql.ResolvedCreateStatementProto;
import com.google.zetasql.AnyResolvedCreateStatementProto;
import com.google.zetasql.ResolvedCreateTableAsSelectStmtProto;
import com.google.zetasql.ResolvedCreateTableFunctionStmtProto;
import com.google.zetasql.ResolvedCreateTableStmtProto;
import com.google.zetasql.ResolvedCreateTableStmtBaseProto;
import com.google.zetasql.AnyResolvedCreateTableStmtBaseProto;
import com.google.zetasql.ResolvedCreateViewBaseProto;
import com.google.zetasql.AnyResolvedCreateViewBaseProto;
import com.google.zetasql.ResolvedCreateViewStmtProto;
import com.google.zetasql.ResolvedDMLDefaultProto;
import com.google.zetasql.ResolvedDMLValueProto;
import com.google.zetasql.ResolvedDefineTableStmtProto;
import com.google.zetasql.ResolvedDeleteStmtProto;
import com.google.zetasql.ResolvedDescribeStmtProto;
import com.google.zetasql.ResolvedDropColumnActionProto;
import com.google.zetasql.ResolvedDropFunctionStmtProto;
import com.google.zetasql.ResolvedDropMaterializedViewStmtProto;
import com.google.zetasql.ResolvedDropRowAccessPolicyStmtProto;
import com.google.zetasql.ResolvedDropStmtProto;
import com.google.zetasql.ResolvedExplainStmtProto;
import com.google.zetasql.ResolvedExportDataStmtProto;
import com.google.zetasql.ResolvedExprProto;
import com.google.zetasql.AnyResolvedExprProto;
import com.google.zetasql.ResolvedExpressionColumnProto;
import com.google.zetasql.ResolvedFilterScanProto;
import com.google.zetasql.ResolvedFilterUsingActionProto;
import com.google.zetasql.ResolvedForeignKeyProto;
import com.google.zetasql.ResolvedFunctionCallProto;
import com.google.zetasql.ResolvedFunctionCallBaseProto;
import com.google.zetasql.AnyResolvedFunctionCallBaseProto;
import com.google.zetasql.ResolvedFunctionSignatureHolderProto;
import com.google.zetasql.ResolvedGeneratedColumnInfoProto;
import com.google.zetasql.ResolvedGetProtoFieldProto;
import com.google.zetasql.ResolvedGetStructFieldProto;
import com.google.zetasql.ResolvedGrantOrRevokeStmtProto;
import com.google.zetasql.AnyResolvedGrantOrRevokeStmtProto;
import com.google.zetasql.ResolvedGrantStmtProto;
import com.google.zetasql.ResolvedGrantToActionProto;
import com.google.zetasql.ResolvedGroupingSetProto;
import com.google.zetasql.ResolvedImportStmtProto;
import com.google.zetasql.ResolvedIndexItemProto;
import com.google.zetasql.ResolvedInsertRowProto;
import com.google.zetasql.ResolvedInsertStmtProto;
import com.google.zetasql.ResolvedJoinScanProto;
import com.google.zetasql.ResolvedLimitOffsetScanProto;
import com.google.zetasql.ResolvedLiteralProto;
import com.google.zetasql.ResolvedMakeProtoProto;
import com.google.zetasql.ResolvedMakeProtoFieldProto;
import com.google.zetasql.ResolvedMakeStructProto;
import com.google.zetasql.ResolvedMergeStmtProto;
import com.google.zetasql.ResolvedMergeWhenProto;
import com.google.zetasql.ResolvedModelProto;
import com.google.zetasql.ResolvedModuleStmtProto;
import com.google.zetasql.ResolvedNonScalarFunctionCallBaseProto;
import com.google.zetasql.AnyResolvedNonScalarFunctionCallBaseProto;
import com.google.zetasql.ResolvedOptionProto;
import com.google.zetasql.ResolvedOrderByItemProto;
import com.google.zetasql.ResolvedOrderByScanProto;
import com.google.zetasql.ResolvedOutputColumnProto;
import com.google.zetasql.ResolvedParameterProto;
import com.google.zetasql.ResolvedPrimaryKeyProto;
import com.google.zetasql.ResolvedPrivilegeProto;
import com.google.zetasql.ResolvedProjectScanProto;
import com.google.zetasql.ResolvedQueryStmtProto;
import com.google.zetasql.ResolvedRelationArgumentScanProto;
import com.google.zetasql.ResolvedRenameStmtProto;
import com.google.zetasql.ResolvedRenameToActionProto;
import com.google.zetasql.ResolvedReplaceFieldProto;
import com.google.zetasql.ResolvedReplaceFieldItemProto;
import com.google.zetasql.ResolvedRevokeFromActionProto;
import com.google.zetasql.ResolvedRevokeStmtProto;
import com.google.zetasql.ResolvedRollbackStmtProto;
import com.google.zetasql.ResolvedRunBatchStmtProto;
import com.google.zetasql.ResolvedSampleScanProto;
import com.google.zetasql.ResolvedScanProto;
import com.google.zetasql.AnyResolvedScanProto;
import com.google.zetasql.ResolvedSetOperationItemProto;
import com.google.zetasql.ResolvedSetOperationScanProto;
import com.google.zetasql.ResolvedSetOptionsActionProto;
import com.google.zetasql.ResolvedSetTransactionStmtProto;
import com.google.zetasql.ResolvedShowStmtProto;
import com.google.zetasql.ResolvedSingleRowScanProto;
import com.google.zetasql.ResolvedStartBatchStmtProto;
import com.google.zetasql.ResolvedStatementProto;
import com.google.zetasql.AnyResolvedStatementProto;
import com.google.zetasql.ResolvedSubqueryExprProto;
import com.google.zetasql.ResolvedSystemVariableProto;
import com.google.zetasql.ResolvedTVFArgumentProto;
import com.google.zetasql.ResolvedTVFScanProto;
import com.google.zetasql.ResolvedTableScanProto;
import com.google.zetasql.ResolvedTruncateStmtProto;
import com.google.zetasql.ResolvedUnnestItemProto;
import com.google.zetasql.ResolvedUpdateArrayItemProto;
import com.google.zetasql.ResolvedUpdateItemProto;
import com.google.zetasql.ResolvedUpdateStmtProto;
import com.google.zetasql.ResolvedWindowFrameProto;
import com.google.zetasql.ResolvedWindowFrameExprProto;
import com.google.zetasql.ResolvedWindowOrderingProto;
import com.google.zetasql.ResolvedWindowPartitioningProto;
import com.google.zetasql.ResolvedWithEntryProto;
import com.google.zetasql.ResolvedWithRefScanProto;
import com.google.zetasql.ResolvedWithScanProto;
import java.util.List;
/**
* This class is a container for all subclasses of {@link ResolvedNode}.
*
* HTML documentation for the class hierarchy is generated in resolved_ast.html.
* A viewable copy is available at (broken link).
*
* In this hierarchy, classes are either abstract or leaves.
*/
public final class ResolvedNodes {
private ResolvedNodes() {}
static ConstantRefProto serialize(Constant constant,
@SuppressWarnings("unused") FileDescriptorSetsBuilder unused) {
return
ConstantRefProto.newBuilder().setName(constant.getFullName()).build();
}
static FunctionRefProto serialize(Function function,
@SuppressWarnings("unused") FileDescriptorSetsBuilder unused) {
return FunctionRefProto.newBuilder().setName(function.getFullName()).build();
}
static FunctionSignatureProto serialize(FunctionSignature functionSignature,
FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
return functionSignature.serialize(fileDescriptorSetsBuilder);
}
static FieldDescriptorRefProto serialize(ZetaSQLFieldDescriptor descriptor,
FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
FieldDescriptorRefProto.Builder fieldDescriptorRef = FieldDescriptorRefProto.newBuilder();
ProtoTypeProto.Builder proto = ProtoTypeProto.newBuilder();
FieldDescriptor fieldDescriptor = descriptor.getDescriptor();
proto.setProtoName(fieldDescriptor.getContainingType().getFullName());
proto.setProtoFileName(fieldDescriptor.getFile().getName());
proto.setFileDescriptorSetIndex(
fileDescriptorSetsBuilder.getOrAddFileDescriptorIndex(
fieldDescriptor.getFile(), descriptor.getZetaSQLDescriptorPool()));
fieldDescriptorRef.setContainingProto(proto.build());
fieldDescriptorRef.setNumber(fieldDescriptor.getNumber());
return fieldDescriptorRef.build();
}
// TODO: Handle serialization of ResolvedFunctionCallInfos.
static ResolvedFunctionCallInfoProto serialize(
ResolvedFunctionCallInfo functionCallContext,
FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
return ResolvedFunctionCallInfoProto.getDefaultInstance();
}
// TODO: Handle serialization of TVFSignatures.
static TVFSignatureProto serialize(
TVFSignature tvfSignature, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
return TVFSignatureProto.getDefaultInstance();
}
// TODO: Handle serialization of TVFs.
static TableValuedFunctionRefProto serialize(
TableValuedFunction tvf, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
return TableValuedFunctionRefProto.getDefaultInstance();
}
static ModelRefProto serialize(Model model, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
return ModelRefProto.newBuilder().setName(model.getName()).setSerializationId(model.getId()).build();
}
static ProcedureRefProto serialize(Procedure procedure,
@SuppressWarnings("unused") FileDescriptorSetsBuilder unused) {
return ProcedureRefProto.newBuilder().setName(procedure.getFullName()).build();
}
static TableRefProto serialize(Table table, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
return TableRefProto.newBuilder().setName(table.getName()).setSerializationId(table.getId()).build();
}
static TypeProto serialize(Type type, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
TypeProto.Builder builder = TypeProto.newBuilder();
type.serialize(builder, fileDescriptorSetsBuilder);
return builder.build();
}
static ValueWithTypeProto serialize(Value value, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
ValueWithTypeProto.Builder builder = ValueWithTypeProto.newBuilder();
if (value.isValid()) {
builder.setType(serialize(value.getType(), fileDescriptorSetsBuilder));
builder.setValue(value.getProto());
}
return builder.build();
}
static ResolvedColumnProto serialize(ResolvedColumn col, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
ResolvedColumnProto.Builder builder = ResolvedColumnProto.newBuilder();
builder.setColumnId(col.getId());
builder.setTableName(col.getTableName());
builder.setName(col.getName());
builder.setType(serialize(col.getType(), fileDescriptorSetsBuilder));
return builder.build();
}
public static ResolvedNode deserialize(
AnyResolvedNodeProto proto, DeserializationHelper helper) {
switch (proto.getNodeCase()) {
case RESOLVED_ARGUMENT_NODE:
return ResolvedArgument.deserialize(proto.getResolvedArgumentNode(), helper);
case RESOLVED_EXPR_NODE:
return ResolvedExpr.deserialize(proto.getResolvedExprNode(), helper);
case RESOLVED_SCAN_NODE:
return ResolvedScan.deserialize(proto.getResolvedScanNode(), helper);
case RESOLVED_STATEMENT_NODE:
return ResolvedStatement.deserialize(proto.getResolvedStatementNode(), helper);
default:
throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase());
}
}
public static AnyResolvedNodeProto serialize(
ResolvedArgument node,
FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedNodeProto.Builder proto = AnyResolvedNodeProto.newBuilder();
AnyResolvedArgumentProto.Builder builder = AnyResolvedArgumentProto.newBuilder();
node.serialize(fileDescriptorSetsBuilder, builder);
proto.setResolvedArgumentNode(builder.build());
return proto.build();
}
public static AnyResolvedNodeProto serialize(
ResolvedExpr node,
FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedNodeProto.Builder proto = AnyResolvedNodeProto.newBuilder();
AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder();
node.serialize(fileDescriptorSetsBuilder, builder);
proto.setResolvedExprNode(builder.build());
return proto.build();
}
public static AnyResolvedNodeProto serialize(
ResolvedScan node,
FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedNodeProto.Builder proto = AnyResolvedNodeProto.newBuilder();
AnyResolvedScanProto.Builder builder = AnyResolvedScanProto.newBuilder();
node.serialize(fileDescriptorSetsBuilder, builder);
proto.setResolvedScanNode(builder.build());
return proto.build();
}
public static AnyResolvedNodeProto serialize(
ResolvedStatement node,
FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedNodeProto.Builder proto = AnyResolvedNodeProto.newBuilder();
AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder();
node.serialize(fileDescriptorSetsBuilder, builder);
proto.setResolvedStatementNode(builder.build());
return proto.build();
}
/**
* A visitor that ResolvedNodes accepts. The default implementation of each
* method is to descend into the AST graph and redispatch to each child node.
* Clients are expected to override {@code visit} methods corresponding
* to the types they are interested in.
*/
public static abstract class Visitor {
protected void defaultVisit(ResolvedNode node) {
node.acceptChildren(this);
}
// private helper method to visit a list of nodes
private void descend(ImmutableList extends ResolvedNode> children) {
children.stream().forEach((child) -> child.accept(this));
}
// private helper method to check for null before visiting a node
private void descend(ResolvedNode child) {
if (child != null) {
child.accept(this);
}
}
public void visit(ResolvedLiteral node) {
defaultVisit(node);
}
public void visit(ResolvedParameter node) {
defaultVisit(node);
}
public void visit(ResolvedExpressionColumn node) {
defaultVisit(node);
}
public void visit(ResolvedColumnRef node) {
defaultVisit(node);
}
public void visit(ResolvedConstant node) {
defaultVisit(node);
}
public void visit(ResolvedSystemVariable node) {
defaultVisit(node);
}
public void visit(ResolvedFunctionCall node) {
defaultVisit(node);
}
public void visit(ResolvedAggregateFunctionCall node) {
defaultVisit(node);
}
public void visit(ResolvedAnalyticFunctionCall node) {
defaultVisit(node);
}
public void visit(ResolvedCast node) {
defaultVisit(node);
}
public void visit(ResolvedMakeStruct node) {
defaultVisit(node);
}
public void visit(ResolvedMakeProto node) {
defaultVisit(node);
}
public void visit(ResolvedMakeProtoField node) {
defaultVisit(node);
}
public void visit(ResolvedGetStructField node) {
defaultVisit(node);
}
public void visit(ResolvedGetProtoField node) {
defaultVisit(node);
}
public void visit(ResolvedReplaceFieldItem node) {
defaultVisit(node);
}
public void visit(ResolvedReplaceField node) {
defaultVisit(node);
}
public void visit(ResolvedSubqueryExpr node) {
defaultVisit(node);
}
public void visit(ResolvedModel node) {
defaultVisit(node);
}
public void visit(ResolvedSingleRowScan node) {
defaultVisit(node);
}
public void visit(ResolvedTableScan node) {
defaultVisit(node);
}
public void visit(ResolvedJoinScan node) {
defaultVisit(node);
}
public void visit(ResolvedArrayScan node) {
defaultVisit(node);
}
public void visit(ResolvedColumnHolder node) {
defaultVisit(node);
}
public void visit(ResolvedFilterScan node) {
defaultVisit(node);
}
public void visit(ResolvedGroupingSet node) {
defaultVisit(node);
}
public void visit(ResolvedAggregateScan node) {
defaultVisit(node);
}
public void visit(ResolvedSetOperationItem node) {
defaultVisit(node);
}
public void visit(ResolvedSetOperationScan node) {
defaultVisit(node);
}
public void visit(ResolvedOrderByScan node) {
defaultVisit(node);
}
public void visit(ResolvedLimitOffsetScan node) {
defaultVisit(node);
}
public void visit(ResolvedWithRefScan node) {
defaultVisit(node);
}
public void visit(ResolvedAnalyticScan node) {
defaultVisit(node);
}
public void visit(ResolvedSampleScan node) {
defaultVisit(node);
}
public void visit(ResolvedComputedColumn node) {
defaultVisit(node);
}
public void visit(ResolvedOrderByItem node) {
defaultVisit(node);
}
public void visit(ResolvedColumnAnnotations node) {
defaultVisit(node);
}
public void visit(ResolvedGeneratedColumnInfo node) {
defaultVisit(node);
}
public void visit(ResolvedColumnDefinition node) {
defaultVisit(node);
}
public void visit(ResolvedPrimaryKey node) {
defaultVisit(node);
}
public void visit(ResolvedForeignKey node) {
defaultVisit(node);
}
public void visit(ResolvedCheckConstraint node) {
defaultVisit(node);
}
public void visit(ResolvedOutputColumn node) {
defaultVisit(node);
}
public void visit(ResolvedProjectScan node) {
defaultVisit(node);
}
public void visit(ResolvedTVFScan node) {
defaultVisit(node);
}
public void visit(ResolvedTVFArgument node) {
defaultVisit(node);
}
public void visit(ResolvedExplainStmt node) {
defaultVisit(node);
}
public void visit(ResolvedQueryStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateDatabaseStmt node) {
defaultVisit(node);
}
public void visit(ResolvedIndexItem node) {
defaultVisit(node);
}
public void visit(ResolvedUnnestItem node) {
defaultVisit(node);
}
public void visit(ResolvedCreateIndexStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateTableStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateTableAsSelectStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateModelStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateViewStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateExternalTableStmt node) {
defaultVisit(node);
}
public void visit(ResolvedExportDataStmt node) {
defaultVisit(node);
}
public void visit(ResolvedDefineTableStmt node) {
defaultVisit(node);
}
public void visit(ResolvedDescribeStmt node) {
defaultVisit(node);
}
public void visit(ResolvedShowStmt node) {
defaultVisit(node);
}
public void visit(ResolvedBeginStmt node) {
defaultVisit(node);
}
public void visit(ResolvedSetTransactionStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCommitStmt node) {
defaultVisit(node);
}
public void visit(ResolvedRollbackStmt node) {
defaultVisit(node);
}
public void visit(ResolvedStartBatchStmt node) {
defaultVisit(node);
}
public void visit(ResolvedRunBatchStmt node) {
defaultVisit(node);
}
public void visit(ResolvedAbortBatchStmt node) {
defaultVisit(node);
}
public void visit(ResolvedDropStmt node) {
defaultVisit(node);
}
public void visit(ResolvedDropMaterializedViewStmt node) {
defaultVisit(node);
}
public void visit(ResolvedWithScan node) {
defaultVisit(node);
}
public void visit(ResolvedWithEntry node) {
defaultVisit(node);
}
public void visit(ResolvedOption node) {
defaultVisit(node);
}
public void visit(ResolvedWindowPartitioning node) {
defaultVisit(node);
}
public void visit(ResolvedWindowOrdering node) {
defaultVisit(node);
}
public void visit(ResolvedWindowFrame node) {
defaultVisit(node);
}
public void visit(ResolvedAnalyticFunctionGroup node) {
defaultVisit(node);
}
public void visit(ResolvedWindowFrameExpr node) {
defaultVisit(node);
}
public void visit(ResolvedDMLValue node) {
defaultVisit(node);
}
public void visit(ResolvedDMLDefault node) {
defaultVisit(node);
}
public void visit(ResolvedAssertStmt node) {
defaultVisit(node);
}
public void visit(ResolvedAssertRowsModified node) {
defaultVisit(node);
}
public void visit(ResolvedInsertRow node) {
defaultVisit(node);
}
public void visit(ResolvedInsertStmt node) {
defaultVisit(node);
}
public void visit(ResolvedDeleteStmt node) {
defaultVisit(node);
}
public void visit(ResolvedUpdateItem node) {
defaultVisit(node);
}
public void visit(ResolvedUpdateArrayItem node) {
defaultVisit(node);
}
public void visit(ResolvedUpdateStmt node) {
defaultVisit(node);
}
public void visit(ResolvedMergeWhen node) {
defaultVisit(node);
}
public void visit(ResolvedMergeStmt node) {
defaultVisit(node);
}
public void visit(ResolvedTruncateStmt node) {
defaultVisit(node);
}
public void visit(ResolvedPrivilege node) {
defaultVisit(node);
}
public void visit(ResolvedGrantStmt node) {
defaultVisit(node);
}
public void visit(ResolvedRevokeStmt node) {
defaultVisit(node);
}
public void visit(ResolvedAlterDatabaseStmt node) {
defaultVisit(node);
}
public void visit(ResolvedAlterMaterializedViewStmt node) {
defaultVisit(node);
}
public void visit(ResolvedAlterTableStmt node) {
defaultVisit(node);
}
public void visit(ResolvedAlterViewStmt node) {
defaultVisit(node);
}
public void visit(ResolvedSetOptionsAction node) {
defaultVisit(node);
}
public void visit(ResolvedAddColumnAction node) {
defaultVisit(node);
}
public void visit(ResolvedDropColumnAction node) {
defaultVisit(node);
}
public void visit(ResolvedAlterTableSetOptionsStmt node) {
defaultVisit(node);
}
public void visit(ResolvedRenameStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateRowAccessPolicyStmt node) {
defaultVisit(node);
}
public void visit(ResolvedDropRowAccessPolicyStmt node) {
defaultVisit(node);
}
public void visit(ResolvedGrantToAction node) {
defaultVisit(node);
}
public void visit(ResolvedFilterUsingAction node) {
defaultVisit(node);
}
public void visit(ResolvedRevokeFromAction node) {
defaultVisit(node);
}
public void visit(ResolvedRenameToAction node) {
defaultVisit(node);
}
public void visit(ResolvedAlterRowAccessPolicyStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateConstantStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateFunctionStmt node) {
defaultVisit(node);
}
public void visit(ResolvedArgumentDef node) {
defaultVisit(node);
}
public void visit(ResolvedArgumentRef node) {
defaultVisit(node);
}
public void visit(ResolvedCreateTableFunctionStmt node) {
defaultVisit(node);
}
public void visit(ResolvedRelationArgumentScan node) {
defaultVisit(node);
}
public void visit(ResolvedArgumentList node) {
defaultVisit(node);
}
public void visit(ResolvedFunctionSignatureHolder node) {
defaultVisit(node);
}
public void visit(ResolvedDropFunctionStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCallStmt node) {
defaultVisit(node);
}
public void visit(ResolvedImportStmt node) {
defaultVisit(node);
}
public void visit(ResolvedModuleStmt node) {
defaultVisit(node);
}
public void visit(ResolvedAggregateHavingModifier node) {
defaultVisit(node);
}
public void visit(ResolvedCreateMaterializedViewStmt node) {
defaultVisit(node);
}
public void visit(ResolvedCreateProcedureStmt node) {
defaultVisit(node);
}
}
/**
* Argument nodes are not self-contained nodes in the tree. They exist
* only to describe parameters to another node (e.g. columns in an OrderBy).
* This node is here for organizational purposes only, to cluster these
* argument nodes.
*/
public static abstract class ResolvedArgument extends ResolvedNode {
protected ResolvedArgument(ResolvedArgumentProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
}
public static ResolvedArgument deserialize(
AnyResolvedArgumentProto proto, DeserializationHelper helper) {
switch (proto.getNodeCase()) {
case RESOLVED_MAKE_PROTO_FIELD_NODE:
return ResolvedMakeProtoField.deserialize(
proto.getResolvedMakeProtoFieldNode(), helper);
case RESOLVED_COLUMN_HOLDER_NODE:
return ResolvedColumnHolder.deserialize(
proto.getResolvedColumnHolderNode(), helper);
case RESOLVED_COMPUTED_COLUMN_NODE:
return ResolvedComputedColumn.deserialize(
proto.getResolvedComputedColumnNode(), helper);
case RESOLVED_ORDER_BY_ITEM_NODE:
return ResolvedOrderByItem.deserialize(
proto.getResolvedOrderByItemNode(), helper);
case RESOLVED_OUTPUT_COLUMN_NODE:
return ResolvedOutputColumn.deserialize(
proto.getResolvedOutputColumnNode(), helper);
case RESOLVED_WITH_ENTRY_NODE:
return ResolvedWithEntry.deserialize(
proto.getResolvedWithEntryNode(), helper);
case RESOLVED_OPTION_NODE:
return ResolvedOption.deserialize(
proto.getResolvedOptionNode(), helper);
case RESOLVED_WINDOW_PARTITIONING_NODE:
return ResolvedWindowPartitioning.deserialize(
proto.getResolvedWindowPartitioningNode(), helper);
case RESOLVED_WINDOW_ORDERING_NODE:
return ResolvedWindowOrdering.deserialize(
proto.getResolvedWindowOrderingNode(), helper);
case RESOLVED_WINDOW_FRAME_NODE:
return ResolvedWindowFrame.deserialize(
proto.getResolvedWindowFrameNode(), helper);
case RESOLVED_ANALYTIC_FUNCTION_GROUP_NODE:
return ResolvedAnalyticFunctionGroup.deserialize(
proto.getResolvedAnalyticFunctionGroupNode(), helper);
case RESOLVED_WINDOW_FRAME_EXPR_NODE:
return ResolvedWindowFrameExpr.deserialize(
proto.getResolvedWindowFrameExprNode(), helper);
case RESOLVED_DMLVALUE_NODE:
return ResolvedDMLValue.deserialize(
proto.getResolvedDmlvalueNode(), helper);
case RESOLVED_ASSERT_ROWS_MODIFIED_NODE:
return ResolvedAssertRowsModified.deserialize(
proto.getResolvedAssertRowsModifiedNode(), helper);
case RESOLVED_INSERT_ROW_NODE:
return ResolvedInsertRow.deserialize(
proto.getResolvedInsertRowNode(), helper);
case RESOLVED_UPDATE_ITEM_NODE:
return ResolvedUpdateItem.deserialize(
proto.getResolvedUpdateItemNode(), helper);
case RESOLVED_PRIVILEGE_NODE:
return ResolvedPrivilege.deserialize(
proto.getResolvedPrivilegeNode(), helper);
case RESOLVED_ARGUMENT_DEF_NODE:
return ResolvedArgumentDef.deserialize(
proto.getResolvedArgumentDefNode(), helper);
case RESOLVED_ARGUMENT_LIST_NODE:
return ResolvedArgumentList.deserialize(
proto.getResolvedArgumentListNode(), helper);
case RESOLVED_TVFARGUMENT_NODE:
return ResolvedTVFArgument.deserialize(
proto.getResolvedTvfargumentNode(), helper);
case RESOLVED_FUNCTION_SIGNATURE_HOLDER_NODE:
return ResolvedFunctionSignatureHolder.deserialize(
proto.getResolvedFunctionSignatureHolderNode(), helper);
case RESOLVED_AGGREGATE_HAVING_MODIFIER_NODE:
return ResolvedAggregateHavingModifier.deserialize(
proto.getResolvedAggregateHavingModifierNode(), helper);
case RESOLVED_COLUMN_DEFINITION_NODE:
return ResolvedColumnDefinition.deserialize(
proto.getResolvedColumnDefinitionNode(), helper);
case RESOLVED_PRIMARY_KEY_NODE:
return ResolvedPrimaryKey.deserialize(
proto.getResolvedPrimaryKeyNode(), helper);
case RESOLVED_GROUPING_SET_NODE:
return ResolvedGroupingSet.deserialize(
proto.getResolvedGroupingSetNode(), helper);
case RESOLVED_SET_OPERATION_ITEM_NODE:
return ResolvedSetOperationItem.deserialize(
proto.getResolvedSetOperationItemNode(), helper);
case RESOLVED_INDEX_ITEM_NODE:
return ResolvedIndexItem.deserialize(
proto.getResolvedIndexItemNode(), helper);
case RESOLVED_MERGE_WHEN_NODE:
return ResolvedMergeWhen.deserialize(
proto.getResolvedMergeWhenNode(), helper);
case RESOLVED_UPDATE_ARRAY_ITEM_NODE:
return ResolvedUpdateArrayItem.deserialize(
proto.getResolvedUpdateArrayItemNode(), helper);
case RESOLVED_COLUMN_ANNOTATIONS_NODE:
return ResolvedColumnAnnotations.deserialize(
proto.getResolvedColumnAnnotationsNode(), helper);
case RESOLVED_GENERATED_COLUMN_INFO_NODE:
return ResolvedGeneratedColumnInfo.deserialize(
proto.getResolvedGeneratedColumnInfoNode(), helper);
case RESOLVED_MODEL_NODE:
return ResolvedModel.deserialize(
proto.getResolvedModelNode(), helper);
case RESOLVED_FOREIGN_KEY_NODE:
return ResolvedForeignKey.deserialize(
proto.getResolvedForeignKeyNode(), helper);
case RESOLVED_CHECK_CONSTRAINT_NODE:
return ResolvedCheckConstraint.deserialize(
proto.getResolvedCheckConstraintNode(), helper);
case RESOLVED_ALTER_ACTION_NODE:
return ResolvedAlterAction.deserialize(
proto.getResolvedAlterActionNode(), helper);
case RESOLVED_UNNEST_ITEM_NODE:
return ResolvedUnnestItem.deserialize(
proto.getResolvedUnnestItemNode(), helper);
case RESOLVED_REPLACE_FIELD_ITEM_NODE:
return ResolvedReplaceFieldItem.deserialize(
proto.getResolvedReplaceFieldItemNode(), helper);
default:
throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase());
}
}
/**
* Serializes this node into a {@link ResolvedArgumentProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
ResolvedArgumentProto.Builder builder = ResolvedArgumentProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedNodeProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedNodeProto.Builder builder) {
builder.clear();
AnyResolvedArgumentProto.Builder childBuilder = AnyResolvedArgumentProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedArgumentNode(childBuilder.build());
}
/**
* Serializes this node into the appropriate field type proto builder
* ({@link AnyResolvedArgumentProto.Builder}) for its parent proto container type.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public abstract void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedArgumentProto.Builder builder);
/**
* Serializes this node into the given {@link ResolvedArgumentProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedArgumentProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedNodeProto parent =
(ResolvedNodeProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
}
}
public static abstract class ResolvedExpr extends ResolvedNode {
private final Type type;
protected ResolvedExpr(ResolvedExprProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
type = helper.deserialize(proto.getType());
}
public static ResolvedExpr deserialize(
AnyResolvedExprProto proto, DeserializationHelper helper) {
switch (proto.getNodeCase()) {
case RESOLVED_LITERAL_NODE:
return ResolvedLiteral.deserialize(
proto.getResolvedLiteralNode(), helper);
case RESOLVED_PARAMETER_NODE:
return ResolvedParameter.deserialize(
proto.getResolvedParameterNode(), helper);
case RESOLVED_EXPRESSION_COLUMN_NODE:
return ResolvedExpressionColumn.deserialize(
proto.getResolvedExpressionColumnNode(), helper);
case RESOLVED_COLUMN_REF_NODE:
return ResolvedColumnRef.deserialize(
proto.getResolvedColumnRefNode(), helper);
case RESOLVED_FUNCTION_CALL_BASE_NODE:
return ResolvedFunctionCallBase.deserialize(
proto.getResolvedFunctionCallBaseNode(), helper);
case RESOLVED_CAST_NODE:
return ResolvedCast.deserialize(
proto.getResolvedCastNode(), helper);
case RESOLVED_MAKE_STRUCT_NODE:
return ResolvedMakeStruct.deserialize(
proto.getResolvedMakeStructNode(), helper);
case RESOLVED_MAKE_PROTO_NODE:
return ResolvedMakeProto.deserialize(
proto.getResolvedMakeProtoNode(), helper);
case RESOLVED_GET_STRUCT_FIELD_NODE:
return ResolvedGetStructField.deserialize(
proto.getResolvedGetStructFieldNode(), helper);
case RESOLVED_GET_PROTO_FIELD_NODE:
return ResolvedGetProtoField.deserialize(
proto.getResolvedGetProtoFieldNode(), helper);
case RESOLVED_SUBQUERY_EXPR_NODE:
return ResolvedSubqueryExpr.deserialize(
proto.getResolvedSubqueryExprNode(), helper);
case RESOLVED_DMLDEFAULT_NODE:
return ResolvedDMLDefault.deserialize(
proto.getResolvedDmldefaultNode(), helper);
case RESOLVED_ARGUMENT_REF_NODE:
return ResolvedArgumentRef.deserialize(
proto.getResolvedArgumentRefNode(), helper);
case RESOLVED_CONSTANT_NODE:
return ResolvedConstant.deserialize(
proto.getResolvedConstantNode(), helper);
case RESOLVED_REPLACE_FIELD_NODE:
return ResolvedReplaceField.deserialize(
proto.getResolvedReplaceFieldNode(), helper);
case RESOLVED_SYSTEM_VARIABLE_NODE:
return ResolvedSystemVariable.deserialize(
proto.getResolvedSystemVariableNode(), helper);
default:
throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase());
}
}
/**
* Serializes this node into a {@link ResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
ResolvedExprProto.Builder builder = ResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedNodeProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedNodeProto.Builder builder) {
builder.clear();
AnyResolvedExprProto.Builder childBuilder = AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedExprNode(childBuilder.build());
}
/**
* Serializes this node into the appropriate field type proto builder
* ({@link AnyResolvedExprProto.Builder}) for its parent proto container type.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public abstract void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder);
/**
* Serializes this node into the given {@link ResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedExprProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedNodeProto parent =
(ResolvedNodeProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// type is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getType() != null) {
proto.setType(
ResolvedNodes.serialize(this.getType(),
fileDescriptorSetsBuilder));
}
}
public final Type getType() {
return type;
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (!DebugStrings.isDefaultValue(type)) {
fields.add(new DebugStringField("type", DebugStrings.toStringImpl(type)));
}
}
}
/**
* Any literal value, including NULL literals.
* There is a special-cased constructor here that gets the type from the
* Value.
*/
public static final class ResolvedLiteral extends ResolvedExpr {
private final Value value;
/**
* If true, then the literal is explicitly typed and cannot be used
* for literal coercions.
*
* This exists mainly for resolver bookkeeping and should be ignored
* by engines.
*/
private final boolean hasExplicitType;
/**
* Distinct ID of the literal, if it is a floating point value,
* within the resolved AST. When coercing from floating point
* to NUMERIC, the resolver uses the float_literal_id to find the
* original image of the literal to avoid precision loss. An ID of 0
* represents a literal without a cached image.
*/
private final long floatLiteralId;
protected ResolvedLiteral(ResolvedLiteralProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
value = helper.deserialize(proto.getValue());
hasExplicitType = proto.getHasExplicitType();
floatLiteralId = proto.getFloatLiteralId();
}
public static final ResolvedLiteral deserialize(
ResolvedLiteralProto proto, DeserializationHelper helper) {
return new ResolvedLiteral(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_LITERAL;
}
@Override
public final String nodeKindString() {
return "Literal";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedLiteralProto.Builder childBuilder = ResolvedLiteralProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedLiteralNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedLiteralProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedLiteralProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// value is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getValue() != null) {
proto.setValue(
ResolvedNodes.serialize(this.getValue(),
fileDescriptorSetsBuilder));
}
// hasExplicitType is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setHasExplicitType(this.getHasExplicitType());
// floatLiteralId is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setFloatLiteralId(this.getFloatLiteralId());
}
public final Value getValue() {
return value;
}
/**
* If true, then the literal is explicitly typed and cannot be used
* for literal coercions.
*
*
This exists mainly for resolver bookkeeping and should be ignored
* by engines.
*/
public final boolean getHasExplicitType() {
return hasExplicitType;
}
/**
* Distinct ID of the literal, if it is a floating point value,
* within the resolved AST. When coercing from floating point
* to NUMERIC, the resolver uses the float_literal_id to find the
* original image of the literal to avoid precision loss. An ID of 0
* represents a literal without a cached image.
*/
public final long getFloatLiteralId() {
return floatLiteralId;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
{
fields.add(new DebugStringField("value", DebugStrings.toStringImpl(value)));
}
if (!DebugStrings.isDefaultValue(hasExplicitType)) {
fields.add(new DebugStringField("has_explicit_type", DebugStrings.toStringImpl(hasExplicitType)));
}
if (!DebugStrings.isDefaultValue(floatLiteralId)) {
fields.add(new DebugStringField("float_literal_id", DebugStrings.toStringImpl(floatLiteralId)));
}
}
}
public static final class ResolvedParameter extends ResolvedExpr {
/**
* If non-empty, the name of the parameter.
*
* A ResolvedParameter will have either a name or a position but not
* both.
*/
private final String name;
/**
* If non-zero, the 1-based position of the positional parameter.
*
*
A ResolvedParameter will have either a name or a position but not
* both.
*/
private final long position;
/**
* If true, then the parameter has no specified type.
*
*
This exists mainly for resolver bookkeeping and should be ignored
* by engines.
*/
private final boolean isUntyped;
protected ResolvedParameter(ResolvedParameterProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
name = proto.getName();
position = proto.getPosition();
isUntyped = proto.getIsUntyped();
}
public static final ResolvedParameter deserialize(
ResolvedParameterProto proto, DeserializationHelper helper) {
return new ResolvedParameter(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_PARAMETER;
}
@Override
public final String nodeKindString() {
return "Parameter";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedParameterProto.Builder childBuilder = ResolvedParameterProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedParameterNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedParameterProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedParameterProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// name is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setName(this.getName());
// position is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setPosition(this.getPosition());
// isUntyped is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setIsUntyped(this.getIsUntyped());
}
/**
* If non-empty, the name of the parameter.
*
*
A ResolvedParameter will have either a name or a position but not
* both.
*/
public final String getName() {
return name;
}
/**
* If non-zero, the 1-based position of the positional parameter.
*
*
A ResolvedParameter will have either a name or a position but not
* both.
*/
public final long getPosition() {
return position;
}
/**
* If true, then the parameter has no specified type.
*
*
This exists mainly for resolver bookkeeping and should be ignored
* by engines.
*/
public final boolean getIsUntyped() {
return isUntyped;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (!DebugStrings.isDefaultValue(name)) {
fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name)));
}
if (!DebugStrings.isDefaultValue(position)) {
fields.add(new DebugStringField("position", DebugStrings.toStringImpl(position)));
}
if (!DebugStrings.isDefaultValue(isUntyped)) {
fields.add(new DebugStringField("is_untyped", DebugStrings.toStringImpl(isUntyped)));
}
}
}
/**
* This represents a column when analyzing a standalone expression.
* This is only used when the analyzer was called using AnalyzeExpression.
* Expression column names and types come from
* AnalyzerOptions::AddExpressionColumn.
* will always be in lowercase.
*/
public static final class ResolvedExpressionColumn extends ResolvedExpr {
private final String name;
protected ResolvedExpressionColumn(ResolvedExpressionColumnProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
name = proto.getName();
}
public static final ResolvedExpressionColumn deserialize(
ResolvedExpressionColumnProto proto, DeserializationHelper helper) {
return new ResolvedExpressionColumn(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_EXPRESSION_COLUMN;
}
@Override
public final String nodeKindString() {
return "ExpressionColumn";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedExpressionColumnProto.Builder childBuilder = ResolvedExpressionColumnProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedExpressionColumnNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedExpressionColumnProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedExpressionColumnProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// name is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setName(this.getName());
}
public final String getName() {
return name;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
{
fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name)));
}
}
}
/**
* An expression referencing the value of some column visible in the
* current Scan node.
*
* If is false, this must be a column visible in the Scan
* containing this expression, either because it was produced inside that
* Scan or it is on the of some child of this Scan.
*
* If is true, this references a column from outside a
* subquery that is visible as a correlated column inside.
* The column referenced here must show up on the parameters list for the
* subquery. See ResolvedSubqueryExpr.
*/
public static final class ResolvedColumnRef extends ResolvedExpr {
private final ResolvedColumn column;
private final boolean isCorrelated;
protected ResolvedColumnRef(ResolvedColumnRefProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
column = helper.deserialize(proto.getColumn());
isCorrelated = proto.getIsCorrelated();
}
public static final ResolvedColumnRef deserialize(
ResolvedColumnRefProto proto, DeserializationHelper helper) {
return new ResolvedColumnRef(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_COLUMN_REF;
}
@Override
public final String nodeKindString() {
return "ColumnRef";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedColumnRefProto.Builder childBuilder = ResolvedColumnRefProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedColumnRefNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedColumnRefProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedColumnRefProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// column is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getColumn() != null) {
proto.setColumn(
ResolvedNodes.serialize(this.getColumn(),
fileDescriptorSetsBuilder));
}
// isCorrelated is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setIsCorrelated(this.getIsCorrelated());
}
public final ResolvedColumn getColumn() {
return column;
}
public final boolean getIsCorrelated() {
return isCorrelated;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
{
fields.add(new DebugStringField("column", DebugStrings.toStringImpl(column)));
}
if (!DebugStrings.isDefaultValue(isCorrelated)) {
fields.add(new DebugStringField("is_correlated", DebugStrings.toStringImpl(isCorrelated)));
}
}
}
/**
* A reference to a named constant.
*/
public static final class ResolvedConstant extends ResolvedExpr {
/**
* The matching Constant from the Catalog.
*/
private final Constant constant;
protected ResolvedConstant(ResolvedConstantProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
constant = helper.deserialize(proto.getConstant());
}
public static final ResolvedConstant deserialize(
ResolvedConstantProto proto, DeserializationHelper helper) {
return new ResolvedConstant(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_CONSTANT;
}
@Override
public final String nodeKindString() {
return "Constant";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedConstantProto.Builder childBuilder = ResolvedConstantProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedConstantNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedConstantProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedConstantProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// constant is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getConstant() != null) {
proto.setConstant(
ResolvedNodes.serialize(this.getConstant(),
fileDescriptorSetsBuilder));
}
}
/**
* The matching Constant from the Catalog.
*/
public final Constant getConstant() {
return constant;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
DebugStrings.collectDebugStringFields(this, fields);
}
protected String getNameForDebugString() {
return DebugStrings.getNameForDebugString(this);
}
}
/**
* A reference to a system variable.
*/
public static final class ResolvedSystemVariable extends ResolvedExpr {
/**
* Path to system variable.
*/
private final ImmutableList namePath;
protected ResolvedSystemVariable(ResolvedSystemVariableProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
namePath =
ImmutableList.copyOf(proto.getNamePathList());
}
public static final ResolvedSystemVariable deserialize(
ResolvedSystemVariableProto proto, DeserializationHelper helper) {
return new ResolvedSystemVariable(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_SYSTEM_VARIABLE;
}
@Override
public final String nodeKindString() {
return "SystemVariable";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedSystemVariableProto.Builder childBuilder = ResolvedSystemVariableProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedSystemVariableNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedSystemVariableProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedSystemVariableProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// namePath is a collection of leaf types that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.addAllNamePath(this.getNamePath());
}
/**
* Path to system variable.
*/
public final ImmutableList getNamePath() {
return namePath;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
DebugStrings.collectDebugStringFields(this, fields);
}
protected String getNameForDebugString() {
return DebugStrings.getNameForDebugString(this);
}
}
/**
* Common base class for scalar and aggregate function calls.
*/
public static abstract class ResolvedFunctionCallBase extends ResolvedExpr {
/**
* The matching Function from the Catalog.
*/
private final Function function;
/**
* The concrete FunctionSignature reflecting the matching Function
* signature and the function's resolved input .
* The function has the mode AGGREGATE iff it is an aggregate
* function, in which case this node must be either
* ResolvedAggregateFunctionCall or ResolvedAnalyticFunctionCall.
*/
private final FunctionSignature signature;
private final ImmutableList argumentList;
/**
* If error_mode=SAFE_ERROR_MODE, and if this function call returns a
* semantic error (based on input data, not transient server
* problems), return NULL instead of an error. This is used for
* functions called using SAFE, as in SAFE.FUNCTION(...).
*/
private final ErrorMode errorMode;
protected ResolvedFunctionCallBase(ResolvedFunctionCallBaseProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
function = helper.deserialize(proto.getFunction());
signature = helper.deserialize(proto.getSignature());
ImmutableList.Builder argumentListBuilder =
ImmutableList.builder();
for (AnyResolvedExprProto element : proto.getArgumentListList()) {
argumentListBuilder
.add(ResolvedExpr.deserialize(element, helper));
}
argumentList = argumentListBuilder.build();
errorMode = proto.getErrorMode();
}
public static ResolvedFunctionCallBase deserialize(
AnyResolvedFunctionCallBaseProto proto, DeserializationHelper helper) {
switch (proto.getNodeCase()) {
case RESOLVED_FUNCTION_CALL_NODE:
return ResolvedFunctionCall.deserialize(
proto.getResolvedFunctionCallNode(), helper);
case RESOLVED_NON_SCALAR_FUNCTION_CALL_BASE_NODE:
return ResolvedNonScalarFunctionCallBase.deserialize(
proto.getResolvedNonScalarFunctionCallBaseNode(), helper);
default:
throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase());
}
}
/**
* Serializes this node into a {@link ResolvedFunctionCallBaseProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
ResolvedFunctionCallBaseProto.Builder builder = ResolvedFunctionCallBaseProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
AnyResolvedFunctionCallBaseProto.Builder childBuilder = AnyResolvedFunctionCallBaseProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedFunctionCallBaseNode(childBuilder.build());
}
/**
* Serializes this node into the appropriate field type proto builder
* ({@link AnyResolvedFunctionCallBaseProto.Builder}) for its parent proto container type.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public abstract void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedFunctionCallBaseProto.Builder builder);
/**
* Serializes this node into the given {@link ResolvedFunctionCallBaseProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedFunctionCallBaseProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// function is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getFunction() != null) {
proto.setFunction(
ResolvedNodes.serialize(this.getFunction(),
fileDescriptorSetsBuilder));
}
// signature is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getSignature() != null) {
proto.setSignature(
ResolvedNodes.serialize(this.getSignature(),
fileDescriptorSetsBuilder));
}
// argumentList is a collection of AST nodes. Serialize each of them.
ImmutableList argumentLists =
this.getArgumentList();
for (ResolvedExpr element : argumentLists) {
AnyResolvedExprProto.Builder argumentListBuilder =
AnyResolvedExprProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, argumentListBuilder);
proto.addArgumentList(argumentListBuilder.build());
}
// errorMode is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setErrorMode(this.getErrorMode());
}
/**
* The matching Function from the Catalog.
*/
public final Function getFunction() {
return function;
}
/**
* The concrete FunctionSignature reflecting the matching Function
* signature and the function's resolved input .
* The function has the mode AGGREGATE iff it is an aggregate
* function, in which case this node must be either
* ResolvedAggregateFunctionCall or ResolvedAnalyticFunctionCall.
*/
public final FunctionSignature getSignature() {
return signature;
}
public final ImmutableList getArgumentList() {
return argumentList;
}
/**
* If error_mode=SAFE_ERROR_MODE, and if this function call returns a
* semantic error (based on input data, not transient server
* problems), return NULL instead of an error. This is used for
* functions called using SAFE, as in SAFE.FUNCTION(...).
*/
public final ErrorMode getErrorMode() {
return errorMode;
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(argumentList);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
DebugStrings.collectDebugStringFields(this, fields);
}
protected String getNameForDebugString() {
return DebugStrings.getNameForDebugString(this);
}
}
/**
* A regular function call. The signature will always have mode SCALAR.
* Most scalar expressions show up as FunctionCalls using builtin signatures.
*/
public static final class ResolvedFunctionCall extends ResolvedFunctionCallBase {
/**
* This contains optional custom information about a particular
* function call.
*
* If some Function subclass requires computing additional
* information at resolving time, that extra information can be
* stored as a subclass of ResolvedFunctionCallInfo here.
* For example, TemplatedSQLFunction stores the resolved template
* body here as a TemplatedSQLFunctionCall.
*
*
This field is ignorable because for most types of function calls,
* there is no extra information to consider besides the arguments
* and other fields from ResolvedFunctionCallBase.
*/
private final ResolvedFunctionCallInfo functionCallInfo;
protected ResolvedFunctionCall(ResolvedFunctionCallProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
functionCallInfo = helper.deserialize(proto.getFunctionCallInfo());
}
public static final ResolvedFunctionCall deserialize(
ResolvedFunctionCallProto proto, DeserializationHelper helper) {
return new ResolvedFunctionCall(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_FUNCTION_CALL;
}
@Override
public final String nodeKindString() {
return "FunctionCall";
}
/**
* Serializes this node into a {@link AnyResolvedFunctionCallBaseProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedFunctionCallBaseProto.Builder builder =
AnyResolvedFunctionCallBaseProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedFunctionCallBaseProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedFunctionCallBaseProto.Builder builder) {
builder.clear();
ResolvedFunctionCallProto.Builder childBuilder = ResolvedFunctionCallProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedFunctionCallNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedFunctionCallProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedFunctionCallProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedFunctionCallBaseProto parent =
(ResolvedFunctionCallBaseProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// functionCallInfo is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getFunctionCallInfo() != null) {
proto.setFunctionCallInfo(
ResolvedNodes.serialize(this.getFunctionCallInfo(),
fileDescriptorSetsBuilder));
}
}
/**
* This contains optional custom information about a particular
* function call.
*
*
If some Function subclass requires computing additional
* information at resolving time, that extra information can be
* stored as a subclass of ResolvedFunctionCallInfo here.
* For example, TemplatedSQLFunction stores the resolved template
* body here as a TemplatedSQLFunctionCall.
*
*
This field is ignorable because for most types of function calls,
* there is no extra information to consider besides the arguments
* and other fields from ResolvedFunctionCallBase.
*/
public final ResolvedFunctionCallInfo getFunctionCallInfo() {
return functionCallInfo;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (!DebugStrings.isDefaultValue(functionCallInfo)) {
fields.add(new DebugStringField("function_call_info", DebugStrings.toStringImpl(functionCallInfo)));
}
}
}
/**
* Common base class for scalar and aggregate function calls.
*/
public static abstract class ResolvedNonScalarFunctionCallBase extends ResolvedFunctionCallBase {
/**
* Apply DISTINCT to the stream of input values before calling
* function.
*/
private final boolean distinct;
/**
* Apply IGNORE/RESPECT NULLS filtering to the stream of input
* values.
*/
private final NullHandlingModifier nullHandlingModifier;
protected ResolvedNonScalarFunctionCallBase(ResolvedNonScalarFunctionCallBaseProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
distinct = proto.getDistinct();
nullHandlingModifier = proto.getNullHandlingModifier();
}
public static ResolvedNonScalarFunctionCallBase deserialize(
AnyResolvedNonScalarFunctionCallBaseProto proto, DeserializationHelper helper) {
switch (proto.getNodeCase()) {
case RESOLVED_AGGREGATE_FUNCTION_CALL_NODE:
return ResolvedAggregateFunctionCall.deserialize(
proto.getResolvedAggregateFunctionCallNode(), helper);
case RESOLVED_ANALYTIC_FUNCTION_CALL_NODE:
return ResolvedAnalyticFunctionCall.deserialize(
proto.getResolvedAnalyticFunctionCallNode(), helper);
default:
throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase());
}
}
/**
* Serializes this node into a {@link ResolvedNonScalarFunctionCallBaseProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
ResolvedNonScalarFunctionCallBaseProto.Builder builder = ResolvedNonScalarFunctionCallBaseProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedFunctionCallBaseProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedFunctionCallBaseProto.Builder builder) {
builder.clear();
AnyResolvedNonScalarFunctionCallBaseProto.Builder childBuilder = AnyResolvedNonScalarFunctionCallBaseProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedNonScalarFunctionCallBaseNode(childBuilder.build());
}
/**
* Serializes this node into the appropriate field type proto builder
* ({@link AnyResolvedNonScalarFunctionCallBaseProto.Builder}) for its parent proto container type.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public abstract void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedNonScalarFunctionCallBaseProto.Builder builder);
/**
* Serializes this node into the given {@link ResolvedNonScalarFunctionCallBaseProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedNonScalarFunctionCallBaseProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedFunctionCallBaseProto parent =
(ResolvedFunctionCallBaseProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// distinct is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setDistinct(this.getDistinct());
// nullHandlingModifier is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setNullHandlingModifier(this.getNullHandlingModifier());
}
/**
* Apply DISTINCT to the stream of input values before calling
* function.
*/
public final boolean getDistinct() {
return distinct;
}
/**
* Apply IGNORE/RESPECT NULLS filtering to the stream of input
* values.
*/
public final NullHandlingModifier getNullHandlingModifier() {
return nullHandlingModifier;
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (!DebugStrings.isDefaultValue(distinct)) {
fields.add(new DebugStringField("distinct", DebugStrings.toStringImpl(distinct)));
}
if (!DebugStrings.isDefaultValue(nullHandlingModifier)) {
fields.add(new DebugStringField("null_handling_modifier", DebugStrings.toStringImpl(nullHandlingModifier)));
}
}
}
/**
* An aggregate function call. The signature always has mode AGGREGATE.
* This node only ever shows up as the outer function call in a
* ResolvedAggregateScan::aggregate_list.
*/
public static final class ResolvedAggregateFunctionCall extends ResolvedNonScalarFunctionCallBase {
/**
* Apply HAVING MAX/MIN filtering to the stream of input values.
*/
private final ResolvedAggregateHavingModifier havingModifier;
/**
* Apply ordering to the stream of input values before calling
* function.
*/
private final ImmutableList orderByItemList;
private final ResolvedExpr limit;
/**
* This contains optional custom information about a particular
* function call. Functions may introduce subclasses of this class to
* add custom information as needed on a per-function basis.
*
* This field is ignorable because for most types of function calls,
* there is no extra information to consider besides the arguments
* and other fields from ResolvedFunctionCallBase. However, for
* example, the TemplateSQLFunction in
* zetasql/public/templated_sql_function.h defines the
* TemplatedSQLFunctionCall subclass which includes the
* fully-resolved function body in context of the actual concrete
* types of the arguments provided to the function call.
*/
private final ResolvedFunctionCallInfo functionCallInfo;
protected ResolvedAggregateFunctionCall(ResolvedAggregateFunctionCallProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasHavingModifier()) {
havingModifier =
ResolvedAggregateHavingModifier.deserialize(proto.getHavingModifier(), helper);
} else {
havingModifier = null;
}
ImmutableList.Builder orderByItemListBuilder =
ImmutableList.builder();
for (ResolvedOrderByItemProto element : proto.getOrderByItemListList()) {
orderByItemListBuilder
.add(ResolvedOrderByItem.deserialize(element, helper));
}
orderByItemList = orderByItemListBuilder.build();
if (proto.hasLimit()) {
limit =
ResolvedExpr.deserialize(proto.getLimit(), helper);
} else {
limit = null;
}
functionCallInfo = helper.deserialize(proto.getFunctionCallInfo());
}
public static final ResolvedAggregateFunctionCall deserialize(
ResolvedAggregateFunctionCallProto proto, DeserializationHelper helper) {
return new ResolvedAggregateFunctionCall(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_AGGREGATE_FUNCTION_CALL;
}
@Override
public final String nodeKindString() {
return "AggregateFunctionCall";
}
/**
* Serializes this node into a {@link AnyResolvedNonScalarFunctionCallBaseProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedNonScalarFunctionCallBaseProto.Builder builder =
AnyResolvedNonScalarFunctionCallBaseProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedNonScalarFunctionCallBaseProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedNonScalarFunctionCallBaseProto.Builder builder) {
builder.clear();
ResolvedAggregateFunctionCallProto.Builder childBuilder = ResolvedAggregateFunctionCallProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedAggregateFunctionCallNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedAggregateFunctionCallProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedAggregateFunctionCallProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedNonScalarFunctionCallBaseProto parent =
(ResolvedNonScalarFunctionCallBaseProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// havingModifier is an AST node. Call its serialization chain.
if (this.getHavingModifier() != null) {
ResolvedAggregateHavingModifierProto.Builder havingModifierBuilder =
ResolvedAggregateHavingModifierProto.newBuilder();
this.getHavingModifier().serialize(
fileDescriptorSetsBuilder, havingModifierBuilder);
proto.setHavingModifier(
havingModifierBuilder.build());
}
// orderByItemList is a collection of AST nodes. Serialize each of them.
ImmutableList orderByItemLists =
this.getOrderByItemList();
for (ResolvedOrderByItem element : orderByItemLists) {
ResolvedOrderByItemProto.Builder orderByItemListBuilder =
ResolvedOrderByItemProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, orderByItemListBuilder);
proto.addOrderByItemList(orderByItemListBuilder.build());
}
// limit is an AST node. Call its serialization chain.
if (this.getLimit() != null) {
AnyResolvedExprProto.Builder limitBuilder =
AnyResolvedExprProto.newBuilder();
this.getLimit().serialize(
fileDescriptorSetsBuilder, limitBuilder);
proto.setLimit(
limitBuilder.build());
}
// functionCallInfo is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getFunctionCallInfo() != null) {
proto.setFunctionCallInfo(
ResolvedNodes.serialize(this.getFunctionCallInfo(),
fileDescriptorSetsBuilder));
}
}
/**
* Apply HAVING MAX/MIN filtering to the stream of input values.
*/
public final ResolvedAggregateHavingModifier getHavingModifier() {
return havingModifier;
}
/**
* Apply ordering to the stream of input values before calling
* function.
*/
public final ImmutableList getOrderByItemList() {
return orderByItemList;
}
public final ResolvedExpr getLimit() {
return limit;
}
/**
* This contains optional custom information about a particular
* function call. Functions may introduce subclasses of this class to
* add custom information as needed on a per-function basis.
*
* This field is ignorable because for most types of function calls,
* there is no extra information to consider besides the arguments
* and other fields from ResolvedFunctionCallBase. However, for
* example, the TemplateSQLFunction in
* zetasql/public/templated_sql_function.h defines the
* TemplatedSQLFunctionCall subclass which includes the
* fully-resolved function body in context of the actual concrete
* types of the arguments provided to the function call.
*/
public final ResolvedFunctionCallInfo getFunctionCallInfo() {
return functionCallInfo;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(havingModifier);
visitor.descend(orderByItemList);
visitor.descend(limit);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (havingModifier != null) {
fields.add(new DebugStringField("having_modifier", havingModifier));
}
if (!orderByItemList.isEmpty()) {
fields.add(new DebugStringField("order_by_item_list", orderByItemList));
}
if (limit != null) {
fields.add(new DebugStringField("limit", limit));
}
if (!DebugStrings.isDefaultValue(functionCallInfo)) {
fields.add(new DebugStringField("function_call_info", DebugStrings.toStringImpl(functionCallInfo)));
}
}
}
/**
* An analytic function call. The mode of the function is either AGGREGATE
* or ANALYTIC. This node only ever shows up as a function call in a
* ResolvedAnalyticFunctionGroup::analytic_function_list. Its associated
* window is not under this node but as a sibling of its parent node.
*
* can be NULL.
*/
public static final class ResolvedAnalyticFunctionCall extends ResolvedNonScalarFunctionCallBase {
private final ResolvedWindowFrame windowFrame;
protected ResolvedAnalyticFunctionCall(ResolvedAnalyticFunctionCallProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasWindowFrame()) {
windowFrame =
ResolvedWindowFrame.deserialize(proto.getWindowFrame(), helper);
} else {
windowFrame = null;
}
}
public static final ResolvedAnalyticFunctionCall deserialize(
ResolvedAnalyticFunctionCallProto proto, DeserializationHelper helper) {
return new ResolvedAnalyticFunctionCall(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_ANALYTIC_FUNCTION_CALL;
}
@Override
public final String nodeKindString() {
return "AnalyticFunctionCall";
}
/**
* Serializes this node into a {@link AnyResolvedNonScalarFunctionCallBaseProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedNonScalarFunctionCallBaseProto.Builder builder =
AnyResolvedNonScalarFunctionCallBaseProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedNonScalarFunctionCallBaseProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedNonScalarFunctionCallBaseProto.Builder builder) {
builder.clear();
ResolvedAnalyticFunctionCallProto.Builder childBuilder = ResolvedAnalyticFunctionCallProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedAnalyticFunctionCallNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedAnalyticFunctionCallProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedAnalyticFunctionCallProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedNonScalarFunctionCallBaseProto parent =
(ResolvedNonScalarFunctionCallBaseProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// windowFrame is an AST node. Call its serialization chain.
if (this.getWindowFrame() != null) {
ResolvedWindowFrameProto.Builder windowFrameBuilder =
ResolvedWindowFrameProto.newBuilder();
this.getWindowFrame().serialize(
fileDescriptorSetsBuilder, windowFrameBuilder);
proto.setWindowFrame(
windowFrameBuilder.build());
}
}
public final ResolvedWindowFrame getWindowFrame() {
return windowFrame;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(windowFrame);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (windowFrame != null) {
fields.add(new DebugStringField("window_frame", windowFrame));
}
}
}
/**
* A cast expression, casting the result of an input expression to the
* target Type.
*
* Valid casts are defined in the CastHashMap (see cast.cc), which identifies
* valid from-Type, to-Type pairs. Consumers can access it through
* GetZetaSQLCasts().
*/
public static final class ResolvedCast extends ResolvedExpr {
private final ResolvedExpr expr;
/**
* Whether to return NULL if the cast fails. This is set to true for
* SAFE_CAST.
*/
private final boolean returnNullOnError;
protected ResolvedCast(ResolvedCastProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasExpr()) {
expr =
ResolvedExpr.deserialize(proto.getExpr(), helper);
} else {
expr = null;
}
returnNullOnError = proto.getReturnNullOnError();
}
public static final ResolvedCast deserialize(
ResolvedCastProto proto, DeserializationHelper helper) {
return new ResolvedCast(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_CAST;
}
@Override
public final String nodeKindString() {
return "Cast";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedCastProto.Builder childBuilder = ResolvedCastProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedCastNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedCastProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedCastProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// expr is an AST node. Call its serialization chain.
if (this.getExpr() != null) {
AnyResolvedExprProto.Builder exprBuilder =
AnyResolvedExprProto.newBuilder();
this.getExpr().serialize(
fileDescriptorSetsBuilder, exprBuilder);
proto.setExpr(
exprBuilder.build());
}
// returnNullOnError is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setReturnNullOnError(this.getReturnNullOnError());
}
public final ResolvedExpr getExpr() {
return expr;
}
/**
* Whether to return NULL if the cast fails. This is set to true for
* SAFE_CAST.
*/
public final boolean getReturnNullOnError() {
return returnNullOnError;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(expr);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
DebugStrings.collectDebugStringFields(this, fields);
}
protected String getNameForDebugString() {
return DebugStrings.getNameForDebugString(this);
}
}
/**
* Construct a struct value. is always a StructType.
* matches 1:1 with the fields in position-wise.
* Each field's type will match the corresponding field in .
*/
public static final class ResolvedMakeStruct extends ResolvedExpr {
private final ImmutableList fieldList;
protected ResolvedMakeStruct(ResolvedMakeStructProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
ImmutableList.Builder fieldListBuilder =
ImmutableList.builder();
for (AnyResolvedExprProto element : proto.getFieldListList()) {
fieldListBuilder
.add(ResolvedExpr.deserialize(element, helper));
}
fieldList = fieldListBuilder.build();
}
public static final ResolvedMakeStruct deserialize(
ResolvedMakeStructProto proto, DeserializationHelper helper) {
return new ResolvedMakeStruct(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_MAKE_STRUCT;
}
@Override
public final String nodeKindString() {
return "MakeStruct";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedMakeStructProto.Builder childBuilder = ResolvedMakeStructProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedMakeStructNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedMakeStructProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedMakeStructProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// fieldList is a collection of AST nodes. Serialize each of them.
ImmutableList fieldLists =
this.getFieldList();
for (ResolvedExpr element : fieldLists) {
AnyResolvedExprProto.Builder fieldListBuilder =
AnyResolvedExprProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, fieldListBuilder);
proto.addFieldList(fieldListBuilder.build());
}
}
public final ImmutableList getFieldList() {
return fieldList;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(fieldList);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (!fieldList.isEmpty()) {
fields.add(new DebugStringField("field_list", fieldList));
}
}
}
/**
* Construct a proto value. is always a ProtoType.
* is a vector of (FieldDescriptor, expr) pairs to write.
* will contain all required fields, and no duplicate fields.
*/
public static final class ResolvedMakeProto extends ResolvedExpr {
private final ImmutableList fieldList;
protected ResolvedMakeProto(ResolvedMakeProtoProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
ImmutableList.Builder fieldListBuilder =
ImmutableList.builder();
for (ResolvedMakeProtoFieldProto element : proto.getFieldListList()) {
fieldListBuilder
.add(ResolvedMakeProtoField.deserialize(element, helper));
}
fieldList = fieldListBuilder.build();
}
public static final ResolvedMakeProto deserialize(
ResolvedMakeProtoProto proto, DeserializationHelper helper) {
return new ResolvedMakeProto(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_MAKE_PROTO;
}
@Override
public final String nodeKindString() {
return "MakeProto";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedMakeProtoProto.Builder childBuilder = ResolvedMakeProtoProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedMakeProtoNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedMakeProtoProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedMakeProtoProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// fieldList is a collection of AST nodes. Serialize each of them.
ImmutableList fieldLists =
this.getFieldList();
for (ResolvedMakeProtoField element : fieldLists) {
ResolvedMakeProtoFieldProto.Builder fieldListBuilder =
ResolvedMakeProtoFieldProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, fieldListBuilder);
proto.addFieldList(fieldListBuilder.build());
}
}
public final ImmutableList getFieldList() {
return fieldList;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(fieldList);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (!fieldList.isEmpty()) {
fields.add(new DebugStringField("field_list", fieldList));
}
}
}
/**
* One field assignment in a ResolvedMakeProto expression.
* The type of expr will match with the zetasql type of the proto field.
* The type will be an array iff the field is repeated.
*
* For NULL values of , the proto field should be cleared.
*
* If any value of cannot be written into the field, this query
* should fail.
*/
public static final class ResolvedMakeProtoField extends ResolvedArgument {
private final ZetaSQLFieldDescriptor fieldDescriptor;
/**
* Provides the Format annotation that should be used when building
* this field. The annotation specifies both the ZetaSQL type and
* the encoding format for this field.
*/
private final FieldFormat.Format format;
private final ResolvedExpr expr;
protected ResolvedMakeProtoField(ResolvedMakeProtoFieldProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
fieldDescriptor = helper.deserialize(proto.getFieldDescriptor());
format = proto.getFormat();
if (proto.hasExpr()) {
expr =
ResolvedExpr.deserialize(proto.getExpr(), helper);
} else {
expr = null;
}
}
public static final ResolvedMakeProtoField deserialize(
ResolvedMakeProtoFieldProto proto, DeserializationHelper helper) {
return new ResolvedMakeProtoField(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_MAKE_PROTO_FIELD;
}
@Override
public final String nodeKindString() {
return "MakeProtoField";
}
/**
* Serializes this node into a {@link AnyResolvedArgumentProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedArgumentProto.Builder builder =
AnyResolvedArgumentProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedArgumentProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedArgumentProto.Builder builder) {
builder.clear();
ResolvedMakeProtoFieldProto.Builder childBuilder = ResolvedMakeProtoFieldProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedMakeProtoFieldNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedMakeProtoFieldProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedMakeProtoFieldProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedArgumentProto parent =
(ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// fieldDescriptor is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getFieldDescriptor() != null) {
proto.setFieldDescriptor(
ResolvedNodes.serialize(this.getFieldDescriptor(),
fileDescriptorSetsBuilder));
}
// format is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setFormat(this.getFormat());
// expr is an AST node. Call its serialization chain.
if (this.getExpr() != null) {
AnyResolvedExprProto.Builder exprBuilder =
AnyResolvedExprProto.newBuilder();
this.getExpr().serialize(
fileDescriptorSetsBuilder, exprBuilder);
proto.setExpr(
exprBuilder.build());
}
}
public final ZetaSQLFieldDescriptor getFieldDescriptor() {
return fieldDescriptor;
}
/**
* Provides the Format annotation that should be used when building
* this field. The annotation specifies both the ZetaSQL type and
* the encoding format for this field.
*/
public final FieldFormat.Format getFormat() {
return format;
}
public final ResolvedExpr getExpr() {
return expr;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(expr);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
DebugStrings.collectDebugStringFields(this, fields);
}
protected String getNameForDebugString() {
return DebugStrings.getNameForDebugString(this);
}
}
/**
* Get the field in position (0-based) from , which has a
* STRUCT type.
*/
public static final class ResolvedGetStructField extends ResolvedExpr {
private final ResolvedExpr expr;
private final long fieldIdx;
protected ResolvedGetStructField(ResolvedGetStructFieldProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasExpr()) {
expr =
ResolvedExpr.deserialize(proto.getExpr(), helper);
} else {
expr = null;
}
fieldIdx = proto.getFieldIdx();
}
public static final ResolvedGetStructField deserialize(
ResolvedGetStructFieldProto proto, DeserializationHelper helper) {
return new ResolvedGetStructField(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_GET_STRUCT_FIELD;
}
@Override
public final String nodeKindString() {
return "GetStructField";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedGetStructFieldProto.Builder childBuilder = ResolvedGetStructFieldProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedGetStructFieldNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedGetStructFieldProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedGetStructFieldProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// expr is an AST node. Call its serialization chain.
if (this.getExpr() != null) {
AnyResolvedExprProto.Builder exprBuilder =
AnyResolvedExprProto.newBuilder();
this.getExpr().serialize(
fileDescriptorSetsBuilder, exprBuilder);
proto.setExpr(
exprBuilder.build());
}
// fieldIdx is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setFieldIdx(this.getFieldIdx());
}
public final ResolvedExpr getExpr() {
return expr;
}
public final long getFieldIdx() {
return fieldIdx;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(expr);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (expr != null) {
fields.add(new DebugStringField("expr", expr));
}
{
fields.add(new DebugStringField("field_idx", DebugStrings.toStringImpl(fieldIdx)));
}
}
}
public static final class ResolvedGetProtoField extends ResolvedExpr {
private final ResolvedExpr expr;
/**
* The proto2 FieldDescriptor to extract. This provides the tag
* number and wire type. Additional decoding may be necessary if any
* of the other modifiers below are set. Consumers should use those
* ZetaSQL-computed modifiers rather than examining field
* annotations directly.
*
* The field is an extension field iff
* field_descriptor->is_extension() is true. NOTE: The extended
* descriptor's full_name must match the 's type's full_name,
* but may not be the same Descriptor. Extension FieldDescriptors may
* come from a different DescriptorPool.
*
* The field is required if field_descriptor->is_required(). If the
* field is required and not present, an error should result.
*/
private final ZetaSQLFieldDescriptor fieldDescriptor;
/**
* Default value to use when the proto field is not set. The default
* may be NULL (e.g. for proto2 fields with a use_defaults=false
* annotation).
*
*
This will not be filled in (the Value will be uninitialized) if
* get_has_bit is true, or the field is required.
*
*
If field_descriptor->is_required() and the field is not present,
* the engine should return an error.
*
*
If the itself returns NULL, then extracting a field should
* also return NULL, unless is
* true. In that case, the default value is returned.
*
* TODO Make un-ignorable after clients migrate to start
* using it.
*/
private final Value defaultValue;
/**
* Indicates whether to return a bool indicating if a value was
* present, rather than return the value (or NULL). Never set for
* repeated fields. This field cannot be set if
* is true, and vice versa.
* Expression type will be BOOL.
*/
private final boolean getHasBit;
/**
* Provides the Format annotation that should be used when reading
* this field. The annotation specifies both the ZetaSQL type and
* the encoding format for this field. This cannot be set when
* get_has_bit is true.
*/
private final FieldFormat.Format format;
/**
* Indicates that the default value should be returned if is
* NULL.
*
* This can only be set for non-message fields. If the field is a
* proto2 field, then it must be annotated with
* zetasql.use_defaults=true. This cannot be set when
* is true or the field is required.
*/
private final boolean returnDefaultValueWhenUnset;
protected ResolvedGetProtoField(ResolvedGetProtoFieldProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasExpr()) {
expr =
ResolvedExpr.deserialize(proto.getExpr(), helper);
} else {
expr = null;
}
fieldDescriptor = helper.deserialize(proto.getFieldDescriptor());
defaultValue = helper.deserialize(proto.getDefaultValue());
getHasBit = proto.getGetHasBit();
format = proto.getFormat();
returnDefaultValueWhenUnset = proto.getReturnDefaultValueWhenUnset();
}
public static final ResolvedGetProtoField deserialize(
ResolvedGetProtoFieldProto proto, DeserializationHelper helper) {
return new ResolvedGetProtoField(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_GET_PROTO_FIELD;
}
@Override
public final String nodeKindString() {
return "GetProtoField";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedGetProtoFieldProto.Builder childBuilder = ResolvedGetProtoFieldProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedGetProtoFieldNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedGetProtoFieldProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedGetProtoFieldProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// expr is an AST node. Call its serialization chain.
if (this.getExpr() != null) {
AnyResolvedExprProto.Builder exprBuilder =
AnyResolvedExprProto.newBuilder();
this.getExpr().serialize(
fileDescriptorSetsBuilder, exprBuilder);
proto.setExpr(
exprBuilder.build());
}
// fieldDescriptor is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getFieldDescriptor() != null) {
proto.setFieldDescriptor(
ResolvedNodes.serialize(this.getFieldDescriptor(),
fileDescriptorSetsBuilder));
}
// defaultValue is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getDefaultValue() != null) {
proto.setDefaultValue(
ResolvedNodes.serialize(this.getDefaultValue(),
fileDescriptorSetsBuilder));
}
// getHasBit is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setGetHasBit(this.getGetHasBit());
// format is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setFormat(this.getFormat());
// returnDefaultValueWhenUnset is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setReturnDefaultValueWhenUnset(this.getReturnDefaultValueWhenUnset());
}
public final ResolvedExpr getExpr() {
return expr;
}
/**
* The proto2 FieldDescriptor to extract. This provides the tag
* number and wire type. Additional decoding may be necessary if any
* of the other modifiers below are set. Consumers should use those
* ZetaSQL-computed modifiers rather than examining field
* annotations directly.
*
* The field is an extension field iff
* field_descriptor->is_extension() is true. NOTE: The extended
* descriptor's full_name must match the 's type's full_name,
* but may not be the same Descriptor. Extension FieldDescriptors may
* come from a different DescriptorPool.
*
* The field is required if field_descriptor->is_required(). If the
* field is required and not present, an error should result.
*/
public final ZetaSQLFieldDescriptor getFieldDescriptor() {
return fieldDescriptor;
}
/**
* Default value to use when the proto field is not set. The default
* may be NULL (e.g. for proto2 fields with a use_defaults=false
* annotation).
*
*
This will not be filled in (the Value will be uninitialized) if
* get_has_bit is true, or the field is required.
*
*
If field_descriptor->is_required() and the field is not present,
* the engine should return an error.
*
*
If the itself returns NULL, then extracting a field should
* also return NULL, unless is
* true. In that case, the default value is returned.
*
* TODO Make un-ignorable after clients migrate to start
* using it.
*/
public final Value getDefaultValue() {
return defaultValue;
}
/**
* Indicates whether to return a bool indicating if a value was
* present, rather than return the value (or NULL). Never set for
* repeated fields. This field cannot be set if
* is true, and vice versa.
* Expression type will be BOOL.
*/
public final boolean getGetHasBit() {
return getHasBit;
}
/**
* Provides the Format annotation that should be used when reading
* this field. The annotation specifies both the ZetaSQL type and
* the encoding format for this field. This cannot be set when
* get_has_bit is true.
*/
public final FieldFormat.Format getFormat() {
return format;
}
/**
* Indicates that the default value should be returned if is
* NULL.
*
* This can only be set for non-message fields. If the field is a
* proto2 field, then it must be annotated with
* zetasql.use_defaults=true. This cannot be set when
* is true or the field is required.
*/
public final boolean getReturnDefaultValueWhenUnset() {
return returnDefaultValueWhenUnset;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(expr);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (expr != null) {
fields.add(new DebugStringField("expr", expr));
}
{
fields.add(new DebugStringField("field_descriptor", DebugStrings.toStringImpl(fieldDescriptor)));
}
if (!DebugStrings.isDefaultValue(defaultValue)) {
fields.add(new DebugStringField("default_value", DebugStrings.toStringImpl(defaultValue)));
}
if (!DebugStrings.isDefaultValue(getHasBit)) {
fields.add(new DebugStringField("get_has_bit", DebugStrings.toStringImpl(getHasBit)));
}
if (!DebugStrings.isDefaultValue(format)) {
fields.add(new DebugStringField("format", DebugStrings.toStringImpl(format)));
}
if (!DebugStrings.isDefaultValue(returnDefaultValueWhenUnset)) {
fields.add(new DebugStringField("return_default_value_when_unset", DebugStrings.toStringImpl(returnDefaultValueWhenUnset)));
}
}
}
/**
* An argument to the REPLACE_FIELDS() function which specifies a field path
* and a value that this field will be set to. The field path to be modified
* can be constructed through the and
* fields. These vectors correspond to field paths in a STRUCT and PROTO,
* respectively. At least one of these vectors must be non-empty.
*
* If only is non-empty, then the field path only
* references top-level and nested struct fields.
*
* If only is non-empty, then the field path only
* references top-level and nested message fields.
*
* If both and are non-empty, then the
* field path should be expanded starting with . The last
* field in will be the proto from which the first field
* in is extracted.
*
* and the field to be modified must be the same type.
*/
public static final class ResolvedReplaceFieldItem extends ResolvedArgument {
/**
* The value that the final field in will be set
* to.
*
* If is NULL, the field will be unset. If
* is a required field, the engine must return an error if it is set
* to NULL.
*/
private final ResolvedExpr expr;
/**
* A vector of integers that denotes the path to a struct field that
* will be modified. The integer values in this vector correspond to
* field positions (0-based) in a STRUCT. If
* is also non-empty, then the field corresponding to the last index
* in this vector should be of proto type.
*/
private final ImmutableList structIndexPath;
/**
* A vector of FieldDescriptors that denotes the path to a proto
* field that will be modified. If is also
* non-empty, then the first element in this vector should be a
* subfield of the proto corresponding to the last element in
* .
*/
private final ImmutableList protoFieldPath;
protected ResolvedReplaceFieldItem(ResolvedReplaceFieldItemProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasExpr()) {
expr =
ResolvedExpr.deserialize(proto.getExpr(), helper);
} else {
expr = null;
}
structIndexPath =
ImmutableList.copyOf(proto.getStructIndexPathList());
ImmutableList.Builder protoFieldPathBuilder =
ImmutableList.builder();
for (FieldDescriptorRefProto element : proto.getProtoFieldPathList()) {
protoFieldPathBuilder.add(helper.deserialize(element));
}
protoFieldPath = protoFieldPathBuilder.build();
}
public static final ResolvedReplaceFieldItem deserialize(
ResolvedReplaceFieldItemProto proto, DeserializationHelper helper) {
return new ResolvedReplaceFieldItem(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_REPLACE_FIELD_ITEM;
}
@Override
public final String nodeKindString() {
return "ReplaceFieldItem";
}
/**
* Serializes this node into a {@link AnyResolvedArgumentProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedArgumentProto.Builder builder =
AnyResolvedArgumentProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedArgumentProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedArgumentProto.Builder builder) {
builder.clear();
ResolvedReplaceFieldItemProto.Builder childBuilder = ResolvedReplaceFieldItemProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedReplaceFieldItemNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedReplaceFieldItemProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedReplaceFieldItemProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedArgumentProto parent =
(ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// expr is an AST node. Call its serialization chain.
if (this.getExpr() != null) {
AnyResolvedExprProto.Builder exprBuilder =
AnyResolvedExprProto.newBuilder();
this.getExpr().serialize(
fileDescriptorSetsBuilder, exprBuilder);
proto.setExpr(
exprBuilder.build());
}
// structIndexPath is a collection of leaf types that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.addAllStructIndexPath(this.getStructIndexPath());
// protoFieldPath is a collection of leaf types that require a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
ImmutableList protoFieldPaths =
this.getProtoFieldPath();
for (ZetaSQLFieldDescriptor element : protoFieldPaths) {
proto.addProtoFieldPath(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder));
}
}
/**
* The value that the final field in will be set
* to.
*
* If is NULL, the field will be unset. If
* is a required field, the engine must return an error if it is set
* to NULL.
*/
public final ResolvedExpr getExpr() {
return expr;
}
/**
* A vector of integers that denotes the path to a struct field that
* will be modified. The integer values in this vector correspond to
* field positions (0-based) in a STRUCT. If
* is also non-empty, then the field corresponding to the last index
* in this vector should be of proto type.
*/
public final ImmutableList getStructIndexPath() {
return structIndexPath;
}
/**
* A vector of FieldDescriptors that denotes the path to a proto
* field that will be modified. If is also
* non-empty, then the first element in this vector should be a
* subfield of the proto corresponding to the last element in
* .
*/
public final ImmutableList getProtoFieldPath() {
return protoFieldPath;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(expr);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (expr != null) {
fields.add(new DebugStringField("expr", expr));
}
if (!DebugStrings.isDefaultValue(structIndexPath)) {
fields.add(new DebugStringField("struct_index_path", DebugStrings.toStringCommaSeparatedForInt(structIndexPath)));
}
if (!DebugStrings.isDefaultValue(protoFieldPath)) {
fields.add(new DebugStringField("proto_field_path", DebugStrings.toStringPeriodSeparatedForFieldDescriptors(protoFieldPath)));
}
}
}
/**
* Represents a call to the REPLACE_FIELDS() function. This function
* can be used to copy a proto or struct, modify a few fields and
* output the resulting proto or struct. The SQL syntax for this
* function is REPLACE_FIELDS(, ).
*
* See (broken link) for more detail.
*/
public static final class ResolvedReplaceField extends ResolvedExpr {
/**
* The proto/struct to modify.
*/
private final ResolvedExpr expr;
/**
* The list of field paths to be modified along with their new
* values.
*
*
Engines must check at evaluation time that the modifications in
* obey the following rules
* regarding updating protos in ZetaSQL:
* - Modifying a subfield of a NULL-valued proto-valued field is an
* error.
* - Clearing a required field or subfield is an error.
*/
private final ImmutableList replaceFieldItemList;
protected ResolvedReplaceField(ResolvedReplaceFieldProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasExpr()) {
expr =
ResolvedExpr.deserialize(proto.getExpr(), helper);
} else {
expr = null;
}
ImmutableList.Builder replaceFieldItemListBuilder =
ImmutableList.builder();
for (ResolvedReplaceFieldItemProto element : proto.getReplaceFieldItemListList()) {
replaceFieldItemListBuilder
.add(ResolvedReplaceFieldItem.deserialize(element, helper));
}
replaceFieldItemList = replaceFieldItemListBuilder.build();
}
public static final ResolvedReplaceField deserialize(
ResolvedReplaceFieldProto proto, DeserializationHelper helper) {
return new ResolvedReplaceField(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_REPLACE_FIELD;
}
@Override
public final String nodeKindString() {
return "ReplaceField";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedReplaceFieldProto.Builder childBuilder = ResolvedReplaceFieldProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedReplaceFieldNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedReplaceFieldProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedReplaceFieldProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// expr is an AST node. Call its serialization chain.
if (this.getExpr() != null) {
AnyResolvedExprProto.Builder exprBuilder =
AnyResolvedExprProto.newBuilder();
this.getExpr().serialize(
fileDescriptorSetsBuilder, exprBuilder);
proto.setExpr(
exprBuilder.build());
}
// replaceFieldItemList is a collection of AST nodes. Serialize each of them.
ImmutableList replaceFieldItemLists =
this.getReplaceFieldItemList();
for (ResolvedReplaceFieldItem element : replaceFieldItemLists) {
ResolvedReplaceFieldItemProto.Builder replaceFieldItemListBuilder =
ResolvedReplaceFieldItemProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, replaceFieldItemListBuilder);
proto.addReplaceFieldItemList(replaceFieldItemListBuilder.build());
}
}
/**
* The proto/struct to modify.
*/
public final ResolvedExpr getExpr() {
return expr;
}
/**
* The list of field paths to be modified along with their new
* values.
*
* Engines must check at evaluation time that the modifications in
* obey the following rules
* regarding updating protos in ZetaSQL:
* - Modifying a subfield of a NULL-valued proto-valued field is an
* error.
* - Clearing a required field or subfield is an error.
*/
public final ImmutableList getReplaceFieldItemList() {
return replaceFieldItemList;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(expr);
visitor.descend(replaceFieldItemList);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (expr != null) {
fields.add(new DebugStringField("expr", expr));
}
if (!replaceFieldItemList.isEmpty()) {
fields.add(new DebugStringField("replace_field_item_list", replaceFieldItemList));
}
}
}
/**
* A subquery in an expression (not a FROM clause). The subquery runs
* in the context of a single input row and produces a single output value.
*
* Correlated subqueries can be thought of like functions, with a parameter
* list. The gives the set of ResolvedColumns from outside
* the subquery that are used inside.
*
* Inside the subquery, the only allowed references to values outside the
* subquery are to the named ColumnRefs listed in .
* Any reference to one of these parameters will be represented as a
* ResolvedColumnRef with set to true.
*
* These parameters are only visible through one level of expression
* subquery. An expression subquery inside an expression has to list
* parameters again if parameters from the outer query are passed down
* further. (This does not apply for table subqueries inside an expression
* subquery. Table subqueries are never indicated in the resolved AST, so
* Scan nodes inside an expression query may have come from a nested table
* subquery, and they can still reference the expression subquery's
* parameters.)
*
*
An empty means that the subquery is uncorrelated. It is
* permissable to run an uncorrelated subquery only once and reuse the result.
* TODO Do we want to specify semantics more firmly here?
*
* The semantics vary based on SubqueryType:
* SCALAR
* Usage: ( )
* If the subquery produces zero rows, the output value is NULL.
* If the subquery produces exactly one row, that row is the output value.
* If the subquery produces more than one row, raise a runtime error.
*
* ARRAY
* Usage: ARRAY( )
* The subquery produces an array value with zero or more rows, with
* one array element per subquery row produced.
*
* EXISTS
* Usage: EXISTS( )
* The output type is always bool. The result is true if the subquery
* produces at least one row, and false otherwise.
*
* IN
* Usage: [NOT] IN ( )
* The output type is always bool. The result is true when is
* equal to at least one row, and false otherwise. The row
* contains only one column, and the types of and the
* subquery column must exactly match a built-in signature for the
* '$equals' comparison function (they must be the same type or one
* must be INT64 and the other UINT64). NOT will be expressed as a $not
* FunctionCall wrapping this SubqueryExpr.
*
* The subquery for a SCALAR or ARRAY or IN subquery must have exactly one
* output column.
* The output type for a SCALAR or ARRAY subquery is that column's type or
* an array of that column's type. (The subquery scan may include a Project
* with a MakeStruct or MakeProto expression to construct a single value
* from multiple columns.)
*/
public static final class ResolvedSubqueryExpr extends ResolvedExpr {
private final SubqueryType subqueryType;
private final ImmutableList parameterList;
/**
* Field is only populated for subquery of type IN.
*/
private final ResolvedExpr inExpr;
private final ResolvedScan subquery;
/**
* Note: Hints currently happen only for EXISTS or IN subquery but
* not for ARRAY or SCALAR subquery.
*/
private final ImmutableList hintList;
protected ResolvedSubqueryExpr(ResolvedSubqueryExprProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
subqueryType = proto.getSubqueryType();
ImmutableList.Builder parameterListBuilder =
ImmutableList.builder();
for (ResolvedColumnRefProto element : proto.getParameterListList()) {
parameterListBuilder
.add(ResolvedColumnRef.deserialize(element, helper));
}
parameterList = parameterListBuilder.build();
if (proto.hasInExpr()) {
inExpr =
ResolvedExpr.deserialize(proto.getInExpr(), helper);
} else {
inExpr = null;
}
if (proto.hasSubquery()) {
subquery =
ResolvedScan.deserialize(proto.getSubquery(), helper);
} else {
subquery = null;
}
ImmutableList.Builder hintListBuilder =
ImmutableList.builder();
for (ResolvedOptionProto element : proto.getHintListList()) {
hintListBuilder
.add(ResolvedOption.deserialize(element, helper));
}
hintList = hintListBuilder.build();
}
public static final ResolvedSubqueryExpr deserialize(
ResolvedSubqueryExprProto proto, DeserializationHelper helper) {
return new ResolvedSubqueryExpr(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_SUBQUERY_EXPR;
}
@Override
public final String nodeKindString() {
return "SubqueryExpr";
}
/**
* Serializes this node into a {@link AnyResolvedExprProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedExprProto.Builder builder =
AnyResolvedExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedExprProto.Builder builder) {
builder.clear();
ResolvedSubqueryExprProto.Builder childBuilder = ResolvedSubqueryExprProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedSubqueryExprNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedSubqueryExprProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedSubqueryExprProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedExprProto parent =
(ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// subqueryType is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setSubqueryType(this.getSubqueryType());
// parameterList is a collection of AST nodes. Serialize each of them.
ImmutableList parameterLists =
this.getParameterList();
for (ResolvedColumnRef element : parameterLists) {
ResolvedColumnRefProto.Builder parameterListBuilder =
ResolvedColumnRefProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, parameterListBuilder);
proto.addParameterList(parameterListBuilder.build());
}
// inExpr is an AST node. Call its serialization chain.
if (this.getInExpr() != null) {
AnyResolvedExprProto.Builder inExprBuilder =
AnyResolvedExprProto.newBuilder();
this.getInExpr().serialize(
fileDescriptorSetsBuilder, inExprBuilder);
proto.setInExpr(
inExprBuilder.build());
}
// subquery is an AST node. Call its serialization chain.
if (this.getSubquery() != null) {
AnyResolvedScanProto.Builder subqueryBuilder =
AnyResolvedScanProto.newBuilder();
this.getSubquery().serialize(
fileDescriptorSetsBuilder, subqueryBuilder);
proto.setSubquery(
subqueryBuilder.build());
}
// hintList is a collection of AST nodes. Serialize each of them.
ImmutableList hintLists =
this.getHintList();
for (ResolvedOption element : hintLists) {
ResolvedOptionProto.Builder hintListBuilder =
ResolvedOptionProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, hintListBuilder);
proto.addHintList(hintListBuilder.build());
}
}
public final SubqueryType getSubqueryType() {
return subqueryType;
}
public final ImmutableList getParameterList() {
return parameterList;
}
/**
* Field is only populated for subquery of type IN.
*/
public final ResolvedExpr getInExpr() {
return inExpr;
}
public final ResolvedScan getSubquery() {
return subquery;
}
/**
* Note: Hints currently happen only for EXISTS or IN subquery but
* not for ARRAY or SCALAR subquery.
*/
public final ImmutableList getHintList() {
return hintList;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(parameterList);
visitor.descend(inExpr);
visitor.descend(subquery);
visitor.descend(hintList);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
{
fields.add(new DebugStringField("subquery_type", DebugStrings.toStringImpl(subqueryType)));
}
if (!parameterList.isEmpty()) {
fields.add(new DebugStringField("parameter_list", parameterList));
}
if (inExpr != null) {
fields.add(new DebugStringField("in_expr", inExpr));
}
if (subquery != null) {
fields.add(new DebugStringField("subquery", subquery));
}
if (!hintList.isEmpty()) {
fields.add(new DebugStringField("hint_list", hintList));
}
}
}
/**
* Common superclass for all Scans, which are nodes that produce rows
* (e.g. scans, joins, table subqueries). A query's FROM clause is
* represented as a single Scan that composes all input sources into
* a single row stream.
*
* Each Scan has a that says what columns are produced.
* The Scan logically produces a stream of output rows, where each row
* has exactly these columns.
*
* Each Scan may have an attached , storing each hint as
* a ResolvedOption.
*
* If is true, this Scan produces an ordered output, either
* by generating order itself (OrderByScan) or by preserving the order
* of its single input scan (LimitOffsetScan, ProjectScan, or WithScan).
*/
public static abstract class ResolvedScan extends ResolvedNode {
private final ImmutableList columnList;
private final ImmutableList hintList;
private final boolean isOrdered;
protected ResolvedScan(ResolvedScanProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
ImmutableList.Builder columnListBuilder =
ImmutableList.builder();
for (ResolvedColumnProto element : proto.getColumnListList()) {
columnListBuilder.add(helper.deserialize(element));
}
columnList = columnListBuilder.build();
ImmutableList.Builder hintListBuilder =
ImmutableList.builder();
for (ResolvedOptionProto element : proto.getHintListList()) {
hintListBuilder
.add(ResolvedOption.deserialize(element, helper));
}
hintList = hintListBuilder.build();
isOrdered = proto.getIsOrdered();
}
public static ResolvedScan deserialize(
AnyResolvedScanProto proto, DeserializationHelper helper) {
switch (proto.getNodeCase()) {
case RESOLVED_SINGLE_ROW_SCAN_NODE:
return ResolvedSingleRowScan.deserialize(
proto.getResolvedSingleRowScanNode(), helper);
case RESOLVED_TABLE_SCAN_NODE:
return ResolvedTableScan.deserialize(
proto.getResolvedTableScanNode(), helper);
case RESOLVED_JOIN_SCAN_NODE:
return ResolvedJoinScan.deserialize(
proto.getResolvedJoinScanNode(), helper);
case RESOLVED_ARRAY_SCAN_NODE:
return ResolvedArrayScan.deserialize(
proto.getResolvedArrayScanNode(), helper);
case RESOLVED_FILTER_SCAN_NODE:
return ResolvedFilterScan.deserialize(
proto.getResolvedFilterScanNode(), helper);
case RESOLVED_SET_OPERATION_SCAN_NODE:
return ResolvedSetOperationScan.deserialize(
proto.getResolvedSetOperationScanNode(), helper);
case RESOLVED_ORDER_BY_SCAN_NODE:
return ResolvedOrderByScan.deserialize(
proto.getResolvedOrderByScanNode(), helper);
case RESOLVED_LIMIT_OFFSET_SCAN_NODE:
return ResolvedLimitOffsetScan.deserialize(
proto.getResolvedLimitOffsetScanNode(), helper);
case RESOLVED_WITH_REF_SCAN_NODE:
return ResolvedWithRefScan.deserialize(
proto.getResolvedWithRefScanNode(), helper);
case RESOLVED_ANALYTIC_SCAN_NODE:
return ResolvedAnalyticScan.deserialize(
proto.getResolvedAnalyticScanNode(), helper);
case RESOLVED_SAMPLE_SCAN_NODE:
return ResolvedSampleScan.deserialize(
proto.getResolvedSampleScanNode(), helper);
case RESOLVED_PROJECT_SCAN_NODE:
return ResolvedProjectScan.deserialize(
proto.getResolvedProjectScanNode(), helper);
case RESOLVED_WITH_SCAN_NODE:
return ResolvedWithScan.deserialize(
proto.getResolvedWithScanNode(), helper);
case RESOLVED_TVFSCAN_NODE:
return ResolvedTVFScan.deserialize(
proto.getResolvedTvfscanNode(), helper);
case RESOLVED_RELATION_ARGUMENT_SCAN_NODE:
return ResolvedRelationArgumentScan.deserialize(
proto.getResolvedRelationArgumentScanNode(), helper);
case RESOLVED_AGGREGATE_SCAN_BASE_NODE:
return ResolvedAggregateScanBase.deserialize(
proto.getResolvedAggregateScanBaseNode(), helper);
default:
throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase());
}
}
/**
* Serializes this node into a {@link ResolvedScanProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
ResolvedScanProto.Builder builder = ResolvedScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedNodeProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedNodeProto.Builder builder) {
builder.clear();
AnyResolvedScanProto.Builder childBuilder = AnyResolvedScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedScanNode(childBuilder.build());
}
/**
* Serializes this node into the appropriate field type proto builder
* ({@link AnyResolvedScanProto.Builder}) for its parent proto container type.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public abstract void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedScanProto.Builder builder);
/**
* Serializes this node into the given {@link ResolvedScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedScanProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedNodeProto parent =
(ResolvedNodeProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// columnList is a collection of leaf types that require a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
ImmutableList columnLists =
this.getColumnList();
for (ResolvedColumn element : columnLists) {
proto.addColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder));
}
// hintList is a collection of AST nodes. Serialize each of them.
ImmutableList hintLists =
this.getHintList();
for (ResolvedOption element : hintLists) {
ResolvedOptionProto.Builder hintListBuilder =
ResolvedOptionProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, hintListBuilder);
proto.addHintList(hintListBuilder.build());
}
// isOrdered is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setIsOrdered(this.getIsOrdered());
}
public final ImmutableList getColumnList() {
return columnList;
}
public final ImmutableList getHintList() {
return hintList;
}
public final boolean getIsOrdered() {
return isOrdered;
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(hintList);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (!DebugStrings.isDefaultValue(columnList)) {
fields.add(new DebugStringField("column_list", DebugStrings.toStringImpl(columnList)));
}
if (!hintList.isEmpty()) {
fields.add(new DebugStringField("hint_list", hintList));
}
if (!DebugStrings.isDefaultValue(isOrdered)) {
fields.add(new DebugStringField("is_ordered", DebugStrings.toStringImpl(isOrdered)));
}
}
}
/**
* Represents a machine learning model as a TVF argument.
* is the machine learning model object known to the resolver
* (usually through the catalog).
*/
public static final class ResolvedModel extends ResolvedArgument {
private final Model model;
protected ResolvedModel(ResolvedModelProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
model = helper.deserialize(proto.getModel());
}
public static final ResolvedModel deserialize(
ResolvedModelProto proto, DeserializationHelper helper) {
return new ResolvedModel(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_MODEL;
}
@Override
public final String nodeKindString() {
return "Model";
}
/**
* Serializes this node into a {@link AnyResolvedArgumentProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedArgumentProto.Builder builder =
AnyResolvedArgumentProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedArgumentProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedArgumentProto.Builder builder) {
builder.clear();
ResolvedModelProto.Builder childBuilder = ResolvedModelProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedModelNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedModelProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedModelProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedArgumentProto parent =
(ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// model is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getModel() != null) {
proto.setModel(
ResolvedNodes.serialize(this.getModel(),
fileDescriptorSetsBuilder));
}
}
public final Model getModel() {
return model;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
{
fields.add(new DebugStringField("model", DebugStrings.toStringImpl(model)));
}
}
}
/**
* Scan that produces a single row with no columns. Used for queries without
* a FROM clause, where all output comes from the select list.
*/
public static final class ResolvedSingleRowScan extends ResolvedScan {
protected ResolvedSingleRowScan(ResolvedSingleRowScanProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
}
public static final ResolvedSingleRowScan deserialize(
ResolvedSingleRowScanProto proto, DeserializationHelper helper) {
return new ResolvedSingleRowScan(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_SINGLE_ROW_SCAN;
}
@Override
public final String nodeKindString() {
return "SingleRowScan";
}
/**
* Serializes this node into a {@link AnyResolvedScanProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedScanProto.Builder builder =
AnyResolvedScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedScanProto.Builder builder) {
builder.clear();
ResolvedSingleRowScanProto.Builder childBuilder = ResolvedSingleRowScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedSingleRowScanNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedSingleRowScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedSingleRowScanProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedScanProto parent =
(ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
}
}
/**
* Scan a Table.
* The [i] should be matched to a Table column by
* .GetColumn([i]).
*
* If AnalyzerOptions::prune_unused_columns is true, the and
* will include only columns that were referenced
* in the user query. (SELECT * counts as referencing all columns.)
* This column_list can then be used for column-level ACL checking on tables.
*
* for_system_time_expr when non NULL resolves to TIMESTAMP used in
* FOR SYSTEM_TIME AS OF clause. The expression is expected to be constant
* and no columns are visible to it.
*
*
If provided, refers to an explicit alias which was used to
* reference a Table in the user query. If the Table was given an implicitly
* generated alias, then defaults to "".
*
* TODO: Enforce in the constructor arg list. For
* historical reasons, some clients match to Table columns by
* name. All code building this should always set_column_index_list() to
* provide the indexes of all columns in right after the construction
* of a ResolvedTableScan.
*/
public static final class ResolvedTableScan extends ResolvedScan {
private final Table table;
private final ResolvedExpr forSystemTimeExpr;
private final ImmutableList columnIndexList;
private final String alias;
protected ResolvedTableScan(ResolvedTableScanProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
table = helper.deserialize(proto.getTable());
if (proto.hasForSystemTimeExpr()) {
forSystemTimeExpr =
ResolvedExpr.deserialize(proto.getForSystemTimeExpr(), helper);
} else {
forSystemTimeExpr = null;
}
columnIndexList =
ImmutableList.copyOf(proto.getColumnIndexListList());
alias = proto.getAlias();
}
public static final ResolvedTableScan deserialize(
ResolvedTableScanProto proto, DeserializationHelper helper) {
return new ResolvedTableScan(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_TABLE_SCAN;
}
@Override
public final String nodeKindString() {
return "TableScan";
}
/**
* Serializes this node into a {@link AnyResolvedScanProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedScanProto.Builder builder =
AnyResolvedScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedScanProto.Builder builder) {
builder.clear();
ResolvedTableScanProto.Builder childBuilder = ResolvedTableScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedTableScanNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedTableScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedTableScanProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedScanProto parent =
(ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// table is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getTable() != null) {
proto.setTable(
ResolvedNodes.serialize(this.getTable(),
fileDescriptorSetsBuilder));
}
// forSystemTimeExpr is an AST node. Call its serialization chain.
if (this.getForSystemTimeExpr() != null) {
AnyResolvedExprProto.Builder forSystemTimeExprBuilder =
AnyResolvedExprProto.newBuilder();
this.getForSystemTimeExpr().serialize(
fileDescriptorSetsBuilder, forSystemTimeExprBuilder);
proto.setForSystemTimeExpr(
forSystemTimeExprBuilder.build());
}
// columnIndexList is a collection of leaf types that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.addAllColumnIndexList(this.getColumnIndexList());
// alias is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setAlias(this.getAlias());
}
public final Table getTable() {
return table;
}
public final ResolvedExpr getForSystemTimeExpr() {
return forSystemTimeExpr;
}
public final ImmutableList getColumnIndexList() {
return columnIndexList;
}
public final String getAlias() {
return alias;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(forSystemTimeExpr);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
{
fields.add(new DebugStringField("table", DebugStrings.toStringImpl(table)));
}
if (forSystemTimeExpr != null) {
fields.add(new DebugStringField("for_system_time_expr", forSystemTimeExpr));
}
if (!DebugStrings.isDefaultValue(columnIndexList)) {
fields.add(new DebugStringField("column_index_list", DebugStrings.toStringCommaSeparatedForInt(columnIndexList)));
}
if (!DebugStrings.isDefaultValue(alias)) {
fields.add(new DebugStringField("alias", DebugStrings.toStringImpl(alias)));
}
}
}
/**
* A Scan that joins two input scans.
* The will contain columns selected from the union
* of the input scan's .
* When the join is a LEFT/RIGHT/FULL join, ResolvedColumns that came from
* the non-joined side get NULL values.
*/
public static final class ResolvedJoinScan extends ResolvedScan {
private final JoinType joinType;
private final ResolvedScan leftScan;
private final ResolvedScan rightScan;
private final ResolvedExpr joinExpr;
protected ResolvedJoinScan(ResolvedJoinScanProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
joinType = proto.getJoinType();
if (proto.hasLeftScan()) {
leftScan =
ResolvedScan.deserialize(proto.getLeftScan(), helper);
} else {
leftScan = null;
}
if (proto.hasRightScan()) {
rightScan =
ResolvedScan.deserialize(proto.getRightScan(), helper);
} else {
rightScan = null;
}
if (proto.hasJoinExpr()) {
joinExpr =
ResolvedExpr.deserialize(proto.getJoinExpr(), helper);
} else {
joinExpr = null;
}
}
public static final ResolvedJoinScan deserialize(
ResolvedJoinScanProto proto, DeserializationHelper helper) {
return new ResolvedJoinScan(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_JOIN_SCAN;
}
@Override
public final String nodeKindString() {
return "JoinScan";
}
/**
* Serializes this node into a {@link AnyResolvedScanProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedScanProto.Builder builder =
AnyResolvedScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedScanProto.Builder builder) {
builder.clear();
ResolvedJoinScanProto.Builder childBuilder = ResolvedJoinScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedJoinScanNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedJoinScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedJoinScanProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedScanProto parent =
(ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// joinType is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setJoinType(this.getJoinType());
// leftScan is an AST node. Call its serialization chain.
if (this.getLeftScan() != null) {
AnyResolvedScanProto.Builder leftScanBuilder =
AnyResolvedScanProto.newBuilder();
this.getLeftScan().serialize(
fileDescriptorSetsBuilder, leftScanBuilder);
proto.setLeftScan(
leftScanBuilder.build());
}
// rightScan is an AST node. Call its serialization chain.
if (this.getRightScan() != null) {
AnyResolvedScanProto.Builder rightScanBuilder =
AnyResolvedScanProto.newBuilder();
this.getRightScan().serialize(
fileDescriptorSetsBuilder, rightScanBuilder);
proto.setRightScan(
rightScanBuilder.build());
}
// joinExpr is an AST node. Call its serialization chain.
if (this.getJoinExpr() != null) {
AnyResolvedExprProto.Builder joinExprBuilder =
AnyResolvedExprProto.newBuilder();
this.getJoinExpr().serialize(
fileDescriptorSetsBuilder, joinExprBuilder);
proto.setJoinExpr(
joinExprBuilder.build());
}
}
public final JoinType getJoinType() {
return joinType;
}
public final ResolvedScan getLeftScan() {
return leftScan;
}
public final ResolvedScan getRightScan() {
return rightScan;
}
public final ResolvedExpr getJoinExpr() {
return joinExpr;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(leftScan);
visitor.descend(rightScan);
visitor.descend(joinExpr);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (!DebugStrings.isDefaultValue(joinType)) {
fields.add(new DebugStringField("join_type", DebugStrings.toStringImpl(joinType)));
}
if (leftScan != null) {
fields.add(new DebugStringField("left_scan", leftScan));
}
if (rightScan != null) {
fields.add(new DebugStringField("right_scan", rightScan));
}
if (joinExpr != null) {
fields.add(new DebugStringField("join_expr", joinExpr));
}
}
}
/**
* Scan an array value, produced from some expression.
*
* If input_scan is NULL, this scans the given array value and produces
* one row per array element. This can occur when using UNNEST(expression).
*
*
If is non-NULL, for each row in the stream produced by
* input_scan, this evaluates the expression (which must return
* an array type) and then produces a stream with one row per array element.
*
* If is non-NULL, then this condition is evaluated as an ON
* clause for the array join. The named column produced in
* may be used inside .
*
* If the array is empty (after evaluating ), then
* 1. If is false, the scan produces zero rows.
* 2. If is true, the scan produces one row with a NULL value for
* the .
*
* is the new column produced by this scan that stores the
* array element value for each row.
*
* If present, defines the column produced by this
* scan that stores the array offset (0-based) for the corresponding
* .
*
* This node's column_list can have columns from input_scan,
* and .
*/
public static final class ResolvedArrayScan extends ResolvedScan {
private final ResolvedScan inputScan;
private final ResolvedExpr arrayExpr;
private final ResolvedColumn elementColumn;
private final ResolvedColumnHolder arrayOffsetColumn;
private final ResolvedExpr joinExpr;
private final boolean isOuter;
protected ResolvedArrayScan(ResolvedArrayScanProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasInputScan()) {
inputScan =
ResolvedScan.deserialize(proto.getInputScan(), helper);
} else {
inputScan = null;
}
if (proto.hasArrayExpr()) {
arrayExpr =
ResolvedExpr.deserialize(proto.getArrayExpr(), helper);
} else {
arrayExpr = null;
}
elementColumn = helper.deserialize(proto.getElementColumn());
if (proto.hasArrayOffsetColumn()) {
arrayOffsetColumn =
ResolvedColumnHolder.deserialize(proto.getArrayOffsetColumn(), helper);
} else {
arrayOffsetColumn = null;
}
if (proto.hasJoinExpr()) {
joinExpr =
ResolvedExpr.deserialize(proto.getJoinExpr(), helper);
} else {
joinExpr = null;
}
isOuter = proto.getIsOuter();
}
public static final ResolvedArrayScan deserialize(
ResolvedArrayScanProto proto, DeserializationHelper helper) {
return new ResolvedArrayScan(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_ARRAY_SCAN;
}
@Override
public final String nodeKindString() {
return "ArrayScan";
}
/**
* Serializes this node into a {@link AnyResolvedScanProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedScanProto.Builder builder =
AnyResolvedScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedScanProto.Builder builder) {
builder.clear();
ResolvedArrayScanProto.Builder childBuilder = ResolvedArrayScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedArrayScanNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedArrayScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedArrayScanProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedScanProto parent =
(ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// inputScan is an AST node. Call its serialization chain.
if (this.getInputScan() != null) {
AnyResolvedScanProto.Builder inputScanBuilder =
AnyResolvedScanProto.newBuilder();
this.getInputScan().serialize(
fileDescriptorSetsBuilder, inputScanBuilder);
proto.setInputScan(
inputScanBuilder.build());
}
// arrayExpr is an AST node. Call its serialization chain.
if (this.getArrayExpr() != null) {
AnyResolvedExprProto.Builder arrayExprBuilder =
AnyResolvedExprProto.newBuilder();
this.getArrayExpr().serialize(
fileDescriptorSetsBuilder, arrayExprBuilder);
proto.setArrayExpr(
arrayExprBuilder.build());
}
// elementColumn is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getElementColumn() != null) {
proto.setElementColumn(
ResolvedNodes.serialize(this.getElementColumn(),
fileDescriptorSetsBuilder));
}
// arrayOffsetColumn is an AST node. Call its serialization chain.
if (this.getArrayOffsetColumn() != null) {
ResolvedColumnHolderProto.Builder arrayOffsetColumnBuilder =
ResolvedColumnHolderProto.newBuilder();
this.getArrayOffsetColumn().serialize(
fileDescriptorSetsBuilder, arrayOffsetColumnBuilder);
proto.setArrayOffsetColumn(
arrayOffsetColumnBuilder.build());
}
// joinExpr is an AST node. Call its serialization chain.
if (this.getJoinExpr() != null) {
AnyResolvedExprProto.Builder joinExprBuilder =
AnyResolvedExprProto.newBuilder();
this.getJoinExpr().serialize(
fileDescriptorSetsBuilder, joinExprBuilder);
proto.setJoinExpr(
joinExprBuilder.build());
}
// isOuter is a leaf type that can be set as a proto field directly.
// (see scalar types in (broken link).py for more information.)
proto.setIsOuter(this.getIsOuter());
}
public final ResolvedScan getInputScan() {
return inputScan;
}
public final ResolvedExpr getArrayExpr() {
return arrayExpr;
}
public final ResolvedColumn getElementColumn() {
return elementColumn;
}
public final ResolvedColumnHolder getArrayOffsetColumn() {
return arrayOffsetColumn;
}
public final ResolvedExpr getJoinExpr() {
return joinExpr;
}
public final boolean getIsOuter() {
return isOuter;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(inputScan);
visitor.descend(arrayExpr);
visitor.descend(arrayOffsetColumn);
visitor.descend(joinExpr);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (inputScan != null) {
fields.add(new DebugStringField("input_scan", inputScan));
}
if (arrayExpr != null) {
fields.add(new DebugStringField("array_expr", arrayExpr));
}
{
fields.add(new DebugStringField("element_column", DebugStrings.toStringImpl(elementColumn)));
}
if (arrayOffsetColumn != null) {
fields.add(new DebugStringField("array_offset_column", arrayOffsetColumn));
}
if (joinExpr != null) {
fields.add(new DebugStringField("join_expr", joinExpr));
}
if (!DebugStrings.isDefaultValue(isOuter)) {
fields.add(new DebugStringField("is_outer", DebugStrings.toStringImpl(isOuter)));
}
}
}
/**
* This wrapper is used for an optional ResolvedColumn inside another node.
*/
public static final class ResolvedColumnHolder extends ResolvedArgument {
private final ResolvedColumn column;
protected ResolvedColumnHolder(ResolvedColumnHolderProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
column = helper.deserialize(proto.getColumn());
}
public static final ResolvedColumnHolder deserialize(
ResolvedColumnHolderProto proto, DeserializationHelper helper) {
return new ResolvedColumnHolder(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_COLUMN_HOLDER;
}
@Override
public final String nodeKindString() {
return "ColumnHolder";
}
/**
* Serializes this node into a {@link AnyResolvedArgumentProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedArgumentProto.Builder builder =
AnyResolvedArgumentProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedArgumentProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedArgumentProto.Builder builder) {
builder.clear();
ResolvedColumnHolderProto.Builder childBuilder = ResolvedColumnHolderProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedColumnHolderNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedColumnHolderProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedColumnHolderProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedArgumentProto parent =
(ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// column is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getColumn() != null) {
proto.setColumn(
ResolvedNodes.serialize(this.getColumn(),
fileDescriptorSetsBuilder));
}
}
public final ResolvedColumn getColumn() {
return column;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
{
fields.add(new DebugStringField("column", DebugStrings.toStringImpl(column)));
}
}
}
/**
* Scan rows from input_scan, and emit all rows where filter_expr
* evaluates to true. filter_expr is always of type bool.
* This node's column_list will be a subset of input_scan's column_list.
*/
public static final class ResolvedFilterScan extends ResolvedScan {
private final ResolvedScan inputScan;
private final ResolvedExpr filterExpr;
protected ResolvedFilterScan(ResolvedFilterScanProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasInputScan()) {
inputScan =
ResolvedScan.deserialize(proto.getInputScan(), helper);
} else {
inputScan = null;
}
if (proto.hasFilterExpr()) {
filterExpr =
ResolvedExpr.deserialize(proto.getFilterExpr(), helper);
} else {
filterExpr = null;
}
}
public static final ResolvedFilterScan deserialize(
ResolvedFilterScanProto proto, DeserializationHelper helper) {
return new ResolvedFilterScan(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_FILTER_SCAN;
}
@Override
public final String nodeKindString() {
return "FilterScan";
}
/**
* Serializes this node into a {@link AnyResolvedScanProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedScanProto.Builder builder =
AnyResolvedScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedScanProto.Builder builder) {
builder.clear();
ResolvedFilterScanProto.Builder childBuilder = ResolvedFilterScanProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedFilterScanNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedFilterScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedFilterScanProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedScanProto parent =
(ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// inputScan is an AST node. Call its serialization chain.
if (this.getInputScan() != null) {
AnyResolvedScanProto.Builder inputScanBuilder =
AnyResolvedScanProto.newBuilder();
this.getInputScan().serialize(
fileDescriptorSetsBuilder, inputScanBuilder);
proto.setInputScan(
inputScanBuilder.build());
}
// filterExpr is an AST node. Call its serialization chain.
if (this.getFilterExpr() != null) {
AnyResolvedExprProto.Builder filterExprBuilder =
AnyResolvedExprProto.newBuilder();
this.getFilterExpr().serialize(
fileDescriptorSetsBuilder, filterExprBuilder);
proto.setFilterExpr(
filterExprBuilder.build());
}
}
public final ResolvedScan getInputScan() {
return inputScan;
}
public final ResolvedExpr getFilterExpr() {
return filterExpr;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(inputScan);
visitor.descend(filterExpr);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (inputScan != null) {
fields.add(new DebugStringField("input_scan", inputScan));
}
if (filterExpr != null) {
fields.add(new DebugStringField("filter_expr", filterExpr));
}
}
}
/**
* List of group by columns that form a grouping set.
*
* Columns must come from group_by_list in ResolvedAggregateScan.
* group_by_column_list will not contain any duplicates. There may be more
* than one ResolvedGroupingSet in the ResolvedAggregateScan with the same
* columns, however.
*/
public static final class ResolvedGroupingSet extends ResolvedArgument {
private final ImmutableList groupByColumnList;
protected ResolvedGroupingSet(ResolvedGroupingSetProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
ImmutableList.Builder groupByColumnListBuilder =
ImmutableList.builder();
for (ResolvedColumnRefProto element : proto.getGroupByColumnListList()) {
groupByColumnListBuilder
.add(ResolvedColumnRef.deserialize(element, helper));
}
groupByColumnList = groupByColumnListBuilder.build();
}
public static final ResolvedGroupingSet deserialize(
ResolvedGroupingSetProto proto, DeserializationHelper helper) {
return new ResolvedGroupingSet(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_GROUPING_SET;
}
@Override
public final String nodeKindString() {
return "GroupingSet";
}
/**
* Serializes this node into a {@link AnyResolvedArgumentProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
AnyResolvedArgumentProto.Builder builder =
AnyResolvedArgumentProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedArgumentProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedArgumentProto.Builder builder) {
builder.clear();
ResolvedGroupingSetProto.Builder childBuilder = ResolvedGroupingSetProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedGroupingSetNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedGroupingSetProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedGroupingSetProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedArgumentProto parent =
(ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// groupByColumnList is a collection of AST nodes. Serialize each of them.
ImmutableList groupByColumnLists =
this.getGroupByColumnList();
for (ResolvedColumnRef element : groupByColumnLists) {
ResolvedColumnRefProto.Builder groupByColumnListBuilder =
ResolvedColumnRefProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, groupByColumnListBuilder);
proto.addGroupByColumnList(groupByColumnListBuilder.build());
}
}
public final ImmutableList getGroupByColumnList() {
return groupByColumnList;
}
@Override
public void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(groupByColumnList);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (!groupByColumnList.isEmpty()) {
fields.add(new DebugStringField("group_by_column_list", groupByColumnList));
}
}
}
/**
* Base class for aggregation scans. Apply aggregation to rows produced from
* input_scan, and output aggregated rows.
*
* Group by keys in . If is empty,
* aggregate all input rows into one output row.
*
* Compute all aggregations in . All expressions in
* have a ResolvedAggregateFunctionCall with mode
* Function::AGGREGATE as their outermost node.
*
* The output contains only columns produced from
* and . No other columns are visible after
* aggregation.
*/
public static abstract class ResolvedAggregateScanBase extends ResolvedScan {
private final ResolvedScan inputScan;
private final ImmutableList groupByList;
private final ImmutableList aggregateList;
protected ResolvedAggregateScanBase(ResolvedAggregateScanBaseProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasInputScan()) {
inputScan =
ResolvedScan.deserialize(proto.getInputScan(), helper);
} else {
inputScan = null;
}
ImmutableList.Builder groupByListBuilder =
ImmutableList.builder();
for (ResolvedComputedColumnProto element : proto.getGroupByListList()) {
groupByListBuilder
.add(ResolvedComputedColumn.deserialize(element, helper));
}
groupByList = groupByListBuilder.build();
ImmutableList.Builder aggregateListBuilder =
ImmutableList.builder();
for (ResolvedComputedColumnProto element : proto.getAggregateListList()) {
aggregateListBuilder
.add(ResolvedComputedColumn.deserialize(element, helper));
}
aggregateList = aggregateListBuilder.build();
}
public static ResolvedAggregateScanBase deserialize(
AnyResolvedAggregateScanBaseProto proto, DeserializationHelper helper) {
switch (proto.getNodeCase()) {
case RESOLVED_AGGREGATE_SCAN_NODE:
return ResolvedAggregateScan.deserialize(
proto.getResolvedAggregateScanNode(), helper);
default:
throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase());
}
}
/**
* Serializes this node into a {@link ResolvedAggregateScanBaseProto}.
* Adds any new file descriptor sets it encounters to the builder.
*/
@Override
public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
ResolvedAggregateScanBaseProto.Builder builder = ResolvedAggregateScanBaseProto.newBuilder();
serialize(fileDescriptorSetsBuilder, builder);
return builder.build();
}
/**
* Serializes this node into the appropriate field of the provided
* {@link AnyResolvedScanProto.Builder}.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedScanProto.Builder builder) {
builder.clear();
AnyResolvedAggregateScanBaseProto.Builder childBuilder = AnyResolvedAggregateScanBaseProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedAggregateScanBaseNode(childBuilder.build());
}
/**
* Serializes this node into the appropriate field type proto builder
* ({@link AnyResolvedAggregateScanBaseProto.Builder}) for its parent proto container type.
* Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}.
* All preexisting state in the proto builder is cleared.
*/
public abstract void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
AnyResolvedAggregateScanBaseProto.Builder builder);
/**
* Serializes this node into the given {@link ResolvedAggregateScanBaseProto.Builder}.
* Adds any new file descriptor sets it encounters to the builder.
* All preexisting state in the proto builder is cleared.
*/
public final void serialize(
FileDescriptorSetsBuilder fileDescriptorSetsBuilder,
ResolvedAggregateScanBaseProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedScanProto parent =
(ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// inputScan is an AST node. Call its serialization chain.
if (this.getInputScan() != null) {
AnyResolvedScanProto.Builder inputScanBuilder =
AnyResolvedScanProto.newBuilder();
this.getInputScan().serialize(
fileDescriptorSetsBuilder, inputScanBuilder);
proto.setInputScan(
inputScanBuilder.build());
}
// groupByList is a collection of AST nodes. Serialize each of them.
ImmutableList groupByLists =
this.getGroupByList();
for (ResolvedComputedColumn element : groupByLists) {
ResolvedComputedColumnProto.Builder groupByListBuilder =
ResolvedComputedColumnProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, groupByListBuilder);
proto.addGroupByList(groupByListBuilder.build());
}
// aggregateList is a collection of AST nodes. Serialize each of them.
ImmutableList aggregateLists =
this.getAggregateList();
for (ResolvedComputedColumn element : aggregateLists) {
ResolvedComputedColumnProto.Builder aggregateListBuilder =
ResolvedComputedColumnProto.newBuilder();
element.serialize(fileDescriptorSetsBuilder, aggregateListBuilder);
proto.addAggregateList(aggregateListBuilder.build());
}
}
public final ResolvedScan getInputScan() {
return inputScan;
}
public final ImmutableList getGroupByList() {
return groupByList;
}
public final ImmutableList getAggregateList() {
return aggregateList;
}
@Override
protected void acceptChildren(Visitor visitor) {
super.acceptChildren(visitor);
visitor.descend(inputScan);
visitor.descend(groupByList);
visitor.descend(aggregateList);
}
protected void collectDebugStringFields(List fields) {
super.collectDebugStringFields(fields);
if (inputScan != null) {
fields.add(new DebugStringField("input_scan", inputScan));
}
if (!groupByList.isEmpty()) {
fields.add(new DebugStringField("group_by_list", groupByList));
}
if (!aggregateList.isEmpty()) {
fields.add(new DebugStringField("aggregate_list", aggregateList));
}
}
}
/**
* Apply aggregation to rows produced from input_scan, and output aggregated
* rows.
*
* For each item in , output additional rows computing the
* same over the input rows using a particular grouping set.
* The aggregation input values, including , computed columns in
* , and aggregate function arguments in ,
* should be computed just once and then reused as aggregation input for each
* grouping set. (This ensures that ROLLUP rows have correct totals, even
* with non-stable functions in the input.) For each grouping set, the
* elements not included in the