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.base.Preconditions;
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.Connection;
import com.google.zetasql.ConnectionRefProto;
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.ResolvedArgumentDefEnums.ArgumentKind;
import com.google.zetasql.resolvedast.ResolvedBeginStmtEnums.ReadWriteMode;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.CreateMode;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.CreateScope;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.DeterminismLevel;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.SqlSecurity;
import com.google.zetasql.resolvedast.ResolvedForeignKeyEnums.ActionOperation;
import com.google.zetasql.resolvedast.ResolvedForeignKeyEnums.MatchMode;
import com.google.zetasql.resolvedast.ResolvedFunctionCallBaseEnums.ErrorMode;
import com.google.zetasql.resolvedast.ResolvedImportStmtEnums.ImportKind;
import com.google.zetasql.resolvedast.ResolvedInsertStmtEnums.InsertMode;
import com.google.zetasql.resolvedast.ResolvedJoinScanEnums.JoinType;
import com.google.zetasql.resolvedast.ResolvedMergeWhenEnums.ActionType;
import com.google.zetasql.resolvedast.ResolvedMergeWhenEnums.MatchType;
import com.google.zetasql.resolvedast.ResolvedNonScalarFunctionCallBaseEnums.NullHandlingModifier;
import com.google.zetasql.resolvedast.ResolvedOrderByItemEnums.NullOrderMode;
import com.google.zetasql.resolvedast.ResolvedSampleScanEnums.SampleUnit;
import com.google.zetasql.resolvedast.ResolvedSetOperationScanEnums.SetOperationType;
import com.google.zetasql.resolvedast.ResolvedStatementEnums.ObjectAccess;
import com.google.zetasql.resolvedast.ResolvedSubqueryExprEnums.SubqueryType;
import com.google.zetasql.resolvedast.ResolvedWindowFrameEnums.FrameUnit;
import com.google.zetasql.resolvedast.ResolvedWindowFrameExprEnums.BoundaryType;
import com.google.zetasql.AnyResolvedAggregateScanBaseProto;
import com.google.zetasql.AnyResolvedAlterActionProto;
import com.google.zetasql.AnyResolvedAlterObjectStmtProto;
import com.google.zetasql.AnyResolvedArgumentProto;
import com.google.zetasql.AnyResolvedCreateStatementProto;
import com.google.zetasql.AnyResolvedCreateTableStmtBaseProto;
import com.google.zetasql.AnyResolvedCreateViewBaseProto;
import com.google.zetasql.AnyResolvedExprProto;
import com.google.zetasql.AnyResolvedFunctionCallBaseProto;
import com.google.zetasql.AnyResolvedGrantOrRevokeStmtProto;
import com.google.zetasql.AnyResolvedNonScalarFunctionCallBaseProto;
import com.google.zetasql.AnyResolvedScanProto;
import com.google.zetasql.AnyResolvedStatementProto;
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.ResolvedAlterActionProto;
import com.google.zetasql.ResolvedAlterDatabaseStmtProto;
import com.google.zetasql.ResolvedAlterMaterializedViewStmtProto;
import com.google.zetasql.ResolvedAlterObjectStmtProto;
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.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.ResolvedAssignmentStmtProto;
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.ResolvedConnectionProto;
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.ResolvedCreateTableAsSelectStmtProto;
import com.google.zetasql.ResolvedCreateTableFunctionStmtProto;
import com.google.zetasql.ResolvedCreateTableStmtProto;
import com.google.zetasql.ResolvedCreateTableStmtBaseProto;
import com.google.zetasql.ResolvedCreateViewBaseProto;
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.ResolvedExecuteImmediateArgumentProto;
import com.google.zetasql.ResolvedExecuteImmediateStmtProto;
import com.google.zetasql.ResolvedExplainStmtProto;
import com.google.zetasql.ResolvedExportDataStmtProto;
import com.google.zetasql.ResolvedExprProto;
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.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.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.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.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.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 ConnectionRefProto serialize(Connection connection, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
return ConnectionRefProto.newBuilder().setName(connection.getName()).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(ResolvedConnection 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);
}
public void visit(ResolvedExecuteImmediateArgument node) {
defaultVisit(node);
}
public void visit(ResolvedExecuteImmediateStmt node) {
defaultVisit(node);
}
public void visit(ResolvedAssignmentStmt 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 {
ResolvedArgument(ResolvedArgumentProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
}
ResolvedArgument() {
super();
}
@Override
public abstract Builder toBuilder();
public static abstract class Builder extends ResolvedNode.Builder {
private Builder() {}
@Override
public abstract ResolvedArgument build();
@Override
protected void validate() {
super.validate();
}
}
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);
case RESOLVED_CONNECTION_NODE:
return ResolvedConnection.deserialize(
proto.getResolvedConnectionNode(), helper);
case RESOLVED_EXECUTE_IMMEDIATE_ARGUMENT_NODE:
return ResolvedExecuteImmediateArgument.deserialize(
proto.getResolvedExecuteImmediateArgumentNode(), 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;
ResolvedExpr(ResolvedExprProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
type = helper.deserialize(proto.getType());
}
ResolvedExpr(
Type type) {
super();
this.type = type;
}
@Override
public abstract Builder toBuilder();
public static abstract class Builder extends ResolvedNode.Builder {
protected Type type = null;
private Builder() {}
public Builder setType(Type v) {
this.type = v;
Preconditions.checkNotNull(v, "type must not be null");
return this;
}
@Override
public abstract ResolvedExpr build();
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
type != null, "type must be set");
}
}
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;
ResolvedLiteral(ResolvedLiteralProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
value = helper.deserialize(proto.getValue());
hasExplicitType = proto.getHasExplicitType();
floatLiteralId = proto.getFloatLiteralId();
}
ResolvedLiteral(
Type type,
Value value,
boolean hasExplicitType,
long floatLiteralId) {
super(
type);
this.value = value;
this.hasExplicitType = hasExplicitType;
this.floatLiteralId = floatLiteralId;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.value = this.getValue();
builder.hasExplicitType = this.getHasExplicitType();
builder.floatLiteralId = this.getFloatLiteralId();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected Value value = null;
protected Boolean hasExplicitType = null;
protected Long floatLiteralId = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
public Builder setValue(Value v) {
this.value = v;
Preconditions.checkNotNull(v, "value must not be null");
return this;
}
/**
* 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 Builder setHasExplicitType(boolean v) {
this.hasExplicitType = v;
return this;
}
/**
* 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 Builder setFloatLiteralId(long v) {
this.floatLiteralId = v;
return this;
}
@Override
public final ResolvedLiteral build() {
validate();
return new ResolvedLiteral(
type,
value,
hasExplicitType,
floatLiteralId);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
value != null, "value must be set");
Preconditions.checkArgument(
hasExplicitType != null, "hasExplicitType must be set");
Preconditions.checkArgument(
floatLiteralId != null, "floatLiteralId must be set");
}
}
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;
ResolvedParameter(ResolvedParameterProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
name = proto.getName();
position = proto.getPosition();
isUntyped = proto.getIsUntyped();
}
ResolvedParameter(
Type type,
String name,
long position,
boolean isUntyped) {
super(
type);
this.name = name;
this.position = position;
this.isUntyped = isUntyped;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.name = this.getName();
builder.position = this.getPosition();
builder.isUntyped = this.getIsUntyped();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected String name = null;
protected Long position = null;
protected Boolean isUntyped = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
/**
* If non-empty, the name of the parameter.
*
*
A ResolvedParameter will have either a name or a position but not
* both.
*/ public Builder setName(String v) {
this.name = v;
Preconditions.checkNotNull(v, "name must not be null");
return this;
}
/**
* 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 Builder setPosition(long v) {
this.position = v;
return this;
}
/**
* If true, then the parameter has no specified type.
*
*
This exists mainly for resolver bookkeeping and should be ignored
* by engines.
*/ public Builder setIsUntyped(boolean v) {
this.isUntyped = v;
return this;
}
@Override
public final ResolvedParameter build() {
validate();
return new ResolvedParameter(
type,
name,
position,
isUntyped);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
name != null, "name must be set");
Preconditions.checkArgument(
position != null, "position must be set");
Preconditions.checkArgument(
isUntyped != null, "isUntyped must be set");
}
}
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;
ResolvedExpressionColumn(ResolvedExpressionColumnProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
name = proto.getName();
}
ResolvedExpressionColumn(
Type type,
String name) {
super(
type);
this.name = name;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.name = this.getName();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected String name = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
public Builder setName(String v) {
this.name = v;
Preconditions.checkNotNull(v, "name must not be null");
return this;
}
@Override
public final ResolvedExpressionColumn build() {
validate();
return new ResolvedExpressionColumn(
type,
name);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
name != null, "name must be set");
}
}
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;
ResolvedColumnRef(ResolvedColumnRefProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
column = helper.deserialize(proto.getColumn());
isCorrelated = proto.getIsCorrelated();
}
ResolvedColumnRef(
Type type,
ResolvedColumn column,
boolean isCorrelated) {
super(
type);
this.column = column;
this.isCorrelated = isCorrelated;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.column = this.getColumn();
builder.isCorrelated = this.getIsCorrelated();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected ResolvedColumn column = null;
protected Boolean isCorrelated = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
public Builder setColumn(ResolvedColumn v) {
this.column = v;
Preconditions.checkNotNull(v, "column must not be null");
return this;
}
public Builder setIsCorrelated(boolean v) {
this.isCorrelated = v;
return this;
}
@Override
public final ResolvedColumnRef build() {
validate();
return new ResolvedColumnRef(
type,
column,
isCorrelated);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
column != null, "column must be set");
Preconditions.checkArgument(
isCorrelated != null, "isCorrelated must be set");
}
}
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;
ResolvedConstant(ResolvedConstantProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
constant = helper.deserialize(proto.getConstant());
}
ResolvedConstant(
Type type,
Constant constant) {
super(
type);
this.constant = constant;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.constant = this.getConstant();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected Constant constant = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
/**
* The matching Constant from the Catalog.
*/ public Builder setConstant(Constant v) {
this.constant = v;
Preconditions.checkNotNull(v, "constant must not be null");
return this;
}
@Override
public final ResolvedConstant build() {
validate();
return new ResolvedConstant(
type,
constant);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
constant != null, "constant must be set");
}
}
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;
ResolvedSystemVariable(ResolvedSystemVariableProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
namePath =
ImmutableList.copyOf(proto.getNamePathList());
}
ResolvedSystemVariable(
Type type,
ImmutableList namePath) {
super(
type);
this.namePath = namePath;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.namePath = this.getNamePath();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected ImmutableList namePath = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
/**
* Path to system variable.
*/ public Builder setNamePath(List v) {
this.namePath = ImmutableList.copyOf(v);
return this;
}
@Override
public final ResolvedSystemVariable build() {
validate();
return new ResolvedSystemVariable(
type,
namePath);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
namePath != null, "namePath must be set");
}
}
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;
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();
}
ResolvedFunctionCallBase(
Type type,
Function function,
FunctionSignature signature,
ImmutableList argumentList,
ErrorMode errorMode) {
super(
type);
this.function = function;
this.signature = signature;
this.argumentList = argumentList;
this.errorMode = errorMode;
}
@Override
public abstract Builder toBuilder();
public static abstract class Builder extends ResolvedExpr.Builder {
protected Function function = null;
protected FunctionSignature signature = null;
protected ImmutableList argumentList = null;
protected ErrorMode errorMode = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
/**
* The matching Function from the Catalog.
*/ public Builder setFunction(Function v) {
this.function = v;
Preconditions.checkNotNull(v, "function must not be null");
return this;
}
/**
* 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 Builder setSignature(FunctionSignature v) {
this.signature = v;
Preconditions.checkNotNull(v, "signature must not be null");
return this;
}
public Builder setArgumentList(List v) {
this.argumentList = ImmutableList.copyOf(v);
return this;
}
/**
* 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 Builder setErrorMode(ErrorMode v) {
this.errorMode = v;
Preconditions.checkNotNull(v, "errorMode must not be null");
return this;
}
@Override
public abstract ResolvedFunctionCallBase build();
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
function != null, "function must be set");
Preconditions.checkArgument(
signature != null, "signature must be set");
Preconditions.checkArgument(
argumentList != null, "argumentList must be set");
Preconditions.checkArgument(
errorMode != null, "errorMode must be set");
}
}
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;
ResolvedFunctionCall(ResolvedFunctionCallProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
functionCallInfo = helper.deserialize(proto.getFunctionCallInfo());
}
ResolvedFunctionCall(
Type type,
Function function,
FunctionSignature signature,
ImmutableList argumentList,
ErrorMode errorMode,
ResolvedFunctionCallInfo functionCallInfo) {
super(
type,
function,
signature,
argumentList,
errorMode);
this.functionCallInfo = functionCallInfo;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.function = this.getFunction();
builder.signature = this.getSignature();
builder.argumentList = this.getArgumentList();
builder.errorMode = this.getErrorMode();
builder.functionCallInfo = this.getFunctionCallInfo();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedFunctionCallBase.Builder {
protected ResolvedFunctionCallInfo functionCallInfo = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
@Override
public Builder setFunction(Function v) {
super.setFunction(v);
return this;
}
@Override
public Builder setSignature(FunctionSignature v) {
super.setSignature(v);
return this;
}
@Override
public Builder setArgumentList(List v) {
super.setArgumentList(v);
return this;
}
@Override
public Builder setErrorMode(ErrorMode v) {
super.setErrorMode(v);
return this;
}
/**
* 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 Builder setFunctionCallInfo(ResolvedFunctionCallInfo v) {
this.functionCallInfo = v;
Preconditions.checkNotNull(v, "functionCallInfo must not be null");
return this;
}
@Override
public final ResolvedFunctionCall build() {
validate();
return new ResolvedFunctionCall(
type,
function,
signature,
argumentList,
errorMode,
functionCallInfo);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
functionCallInfo != null, "functionCallInfo must be set");
}
}
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;
ResolvedNonScalarFunctionCallBase(ResolvedNonScalarFunctionCallBaseProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
distinct = proto.getDistinct();
nullHandlingModifier = proto.getNullHandlingModifier();
}
ResolvedNonScalarFunctionCallBase(
Type type,
Function function,
FunctionSignature signature,
ImmutableList argumentList,
ErrorMode errorMode,
boolean distinct,
NullHandlingModifier nullHandlingModifier) {
super(
type,
function,
signature,
argumentList,
errorMode);
this.distinct = distinct;
this.nullHandlingModifier = nullHandlingModifier;
}
@Override
public abstract Builder toBuilder();
public static abstract class Builder extends ResolvedFunctionCallBase.Builder {
protected Boolean distinct = null;
protected NullHandlingModifier nullHandlingModifier = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
@Override
public Builder setFunction(Function v) {
super.setFunction(v);
return this;
}
@Override
public Builder setSignature(FunctionSignature v) {
super.setSignature(v);
return this;
}
@Override
public Builder setArgumentList(List v) {
super.setArgumentList(v);
return this;
}
@Override
public Builder setErrorMode(ErrorMode v) {
super.setErrorMode(v);
return this;
}
/**
* Apply DISTINCT to the stream of input values before calling
* function.
*/ public Builder setDistinct(boolean v) {
this.distinct = v;
return this;
}
/**
* Apply IGNORE/RESPECT NULLS filtering to the stream of input
* values.
*/ public Builder setNullHandlingModifier(NullHandlingModifier v) {
this.nullHandlingModifier = v;
Preconditions.checkNotNull(v, "nullHandlingModifier must not be null");
return this;
}
@Override
public abstract ResolvedNonScalarFunctionCallBase build();
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
distinct != null, "distinct must be set");
Preconditions.checkArgument(
nullHandlingModifier != null, "nullHandlingModifier must be set");
}
}
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;
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());
}
ResolvedAggregateFunctionCall(
Type type,
Function function,
FunctionSignature signature,
ImmutableList argumentList,
ErrorMode errorMode,
boolean distinct,
NullHandlingModifier nullHandlingModifier,
ResolvedAggregateHavingModifier havingModifier,
ImmutableList orderByItemList,
ResolvedExpr limit,
ResolvedFunctionCallInfo functionCallInfo) {
super(
type,
function,
signature,
argumentList,
errorMode,
distinct,
nullHandlingModifier);
this.havingModifier = havingModifier;
this.orderByItemList = orderByItemList;
this.limit = limit;
this.functionCallInfo = functionCallInfo;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.function = this.getFunction();
builder.signature = this.getSignature();
builder.argumentList = this.getArgumentList();
builder.errorMode = this.getErrorMode();
builder.distinct = this.getDistinct();
builder.nullHandlingModifier = this.getNullHandlingModifier();
builder.havingModifier = this.getHavingModifier();
builder.orderByItemList = this.getOrderByItemList();
builder.limit = this.getLimit();
builder.functionCallInfo = this.getFunctionCallInfo();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedNonScalarFunctionCallBase.Builder {
protected ResolvedAggregateHavingModifier havingModifier = null;
protected ImmutableList orderByItemList = null;
protected ResolvedExpr limit = null;
protected ResolvedFunctionCallInfo functionCallInfo = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
@Override
public Builder setFunction(Function v) {
super.setFunction(v);
return this;
}
@Override
public Builder setSignature(FunctionSignature v) {
super.setSignature(v);
return this;
}
@Override
public Builder setArgumentList(List v) {
super.setArgumentList(v);
return this;
}
@Override
public Builder setErrorMode(ErrorMode v) {
super.setErrorMode(v);
return this;
}
@Override
public Builder setDistinct(boolean v) {
super.setDistinct(v);
return this;
}
@Override
public Builder setNullHandlingModifier(NullHandlingModifier v) {
super.setNullHandlingModifier(v);
return this;
}
/**
* Apply HAVING MAX/MIN filtering to the stream of input values.
*/ public Builder setHavingModifier(ResolvedAggregateHavingModifier v) {
this.havingModifier = v;
Preconditions.checkNotNull(v, "havingModifier must not be null");
return this;
}
/**
* Apply ordering to the stream of input values before calling
* function.
*/ public Builder setOrderByItemList(List v) {
this.orderByItemList = ImmutableList.copyOf(v);
return this;
}
public Builder setLimit(ResolvedExpr v) {
this.limit = v;
Preconditions.checkNotNull(v, "limit must not be null");
return this;
}
/**
* 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 Builder setFunctionCallInfo(ResolvedFunctionCallInfo v) {
this.functionCallInfo = v;
Preconditions.checkNotNull(v, "functionCallInfo must not be null");
return this;
}
@Override
public final ResolvedAggregateFunctionCall build() {
validate();
return new ResolvedAggregateFunctionCall(
type,
function,
signature,
argumentList,
errorMode,
distinct,
nullHandlingModifier,
havingModifier,
orderByItemList,
limit,
functionCallInfo);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
havingModifier != null, "havingModifier must be set");
Preconditions.checkArgument(
orderByItemList != null, "orderByItemList must be set");
Preconditions.checkArgument(
limit != null, "limit must be set");
Preconditions.checkArgument(
functionCallInfo != null, "functionCallInfo must be set");
}
}
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;
ResolvedAnalyticFunctionCall(ResolvedAnalyticFunctionCallProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasWindowFrame()) {
windowFrame =
ResolvedWindowFrame.deserialize(proto.getWindowFrame(), helper);
} else {
windowFrame = null;
}
}
ResolvedAnalyticFunctionCall(
Type type,
Function function,
FunctionSignature signature,
ImmutableList argumentList,
ErrorMode errorMode,
boolean distinct,
NullHandlingModifier nullHandlingModifier,
ResolvedWindowFrame windowFrame) {
super(
type,
function,
signature,
argumentList,
errorMode,
distinct,
nullHandlingModifier);
this.windowFrame = windowFrame;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.function = this.getFunction();
builder.signature = this.getSignature();
builder.argumentList = this.getArgumentList();
builder.errorMode = this.getErrorMode();
builder.distinct = this.getDistinct();
builder.nullHandlingModifier = this.getNullHandlingModifier();
builder.windowFrame = this.getWindowFrame();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedNonScalarFunctionCallBase.Builder {
protected ResolvedWindowFrame windowFrame = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
@Override
public Builder setFunction(Function v) {
super.setFunction(v);
return this;
}
@Override
public Builder setSignature(FunctionSignature v) {
super.setSignature(v);
return this;
}
@Override
public Builder setArgumentList(List v) {
super.setArgumentList(v);
return this;
}
@Override
public Builder setErrorMode(ErrorMode v) {
super.setErrorMode(v);
return this;
}
@Override
public Builder setDistinct(boolean v) {
super.setDistinct(v);
return this;
}
@Override
public Builder setNullHandlingModifier(NullHandlingModifier v) {
super.setNullHandlingModifier(v);
return this;
}
public Builder setWindowFrame(ResolvedWindowFrame v) {
this.windowFrame = v;
Preconditions.checkNotNull(v, "windowFrame must not be null");
return this;
}
@Override
public final ResolvedAnalyticFunctionCall build() {
validate();
return new ResolvedAnalyticFunctionCall(
type,
function,
signature,
argumentList,
errorMode,
distinct,
nullHandlingModifier,
windowFrame);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
windowFrame != null, "windowFrame must be set");
}
}
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;
ResolvedCast(ResolvedCastProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasExpr()) {
expr =
ResolvedExpr.deserialize(proto.getExpr(), helper);
} else {
expr = null;
}
returnNullOnError = proto.getReturnNullOnError();
}
ResolvedCast(
Type type,
ResolvedExpr expr,
boolean returnNullOnError) {
super(
type);
this.expr = expr;
this.returnNullOnError = returnNullOnError;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.expr = this.getExpr();
builder.returnNullOnError = this.getReturnNullOnError();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected ResolvedExpr expr = null;
protected Boolean returnNullOnError = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
public Builder setExpr(ResolvedExpr v) {
this.expr = v;
Preconditions.checkNotNull(v, "expr must not be null");
return this;
}
/**
* Whether to return NULL if the cast fails. This is set to true for
* SAFE_CAST.
*/ public Builder setReturnNullOnError(boolean v) {
this.returnNullOnError = v;
return this;
}
@Override
public final ResolvedCast build() {
validate();
return new ResolvedCast(
type,
expr,
returnNullOnError);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
expr != null, "expr must be set");
Preconditions.checkArgument(
returnNullOnError != null, "returnNullOnError must be set");
}
}
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;
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();
}
ResolvedMakeStruct(
Type type,
ImmutableList fieldList) {
super(
type);
this.fieldList = fieldList;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.fieldList = this.getFieldList();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected ImmutableList fieldList = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
public Builder setFieldList(List v) {
this.fieldList = ImmutableList.copyOf(v);
return this;
}
@Override
public final ResolvedMakeStruct build() {
validate();
return new ResolvedMakeStruct(
type,
fieldList);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
fieldList != null, "fieldList must be set");
}
}
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;
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();
}
ResolvedMakeProto(
Type type,
ImmutableList fieldList) {
super(
type);
this.fieldList = fieldList;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.fieldList = this.getFieldList();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected ImmutableList fieldList = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
public Builder setFieldList(List v) {
this.fieldList = ImmutableList.copyOf(v);
return this;
}
@Override
public final ResolvedMakeProto build() {
validate();
return new ResolvedMakeProto(
type,
fieldList);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
fieldList != null, "fieldList must be set");
}
}
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;
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;
}
}
ResolvedMakeProtoField(
ZetaSQLFieldDescriptor fieldDescriptor,
FieldFormat.Format format,
ResolvedExpr expr) {
super();
this.fieldDescriptor = fieldDescriptor;
this.format = format;
this.expr = expr;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.fieldDescriptor = this.getFieldDescriptor();
builder.format = this.getFormat();
builder.expr = this.getExpr();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedArgument.Builder {
protected ZetaSQLFieldDescriptor fieldDescriptor = null;
protected FieldFormat.Format format = null;
protected ResolvedExpr expr = null;
private Builder() {}
public Builder setFieldDescriptor(ZetaSQLFieldDescriptor v) {
this.fieldDescriptor = v;
Preconditions.checkNotNull(v, "fieldDescriptor must not be null");
return this;
}
/**
* 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 Builder setFormat(FieldFormat.Format v) {
this.format = v;
Preconditions.checkNotNull(v, "format must not be null");
return this;
}
public Builder setExpr(ResolvedExpr v) {
this.expr = v;
Preconditions.checkNotNull(v, "expr must not be null");
return this;
}
@Override
public final ResolvedMakeProtoField build() {
validate();
return new ResolvedMakeProtoField(
fieldDescriptor,
format,
expr);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
fieldDescriptor != null, "fieldDescriptor must be set");
Preconditions.checkArgument(
format != null, "format must be set");
Preconditions.checkArgument(
expr != null, "expr must be set");
}
}
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;
ResolvedGetStructField(ResolvedGetStructFieldProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
if (proto.hasExpr()) {
expr =
ResolvedExpr.deserialize(proto.getExpr(), helper);
} else {
expr = null;
}
fieldIdx = proto.getFieldIdx();
}
ResolvedGetStructField(
Type type,
ResolvedExpr expr,
long fieldIdx) {
super(
type);
this.expr = expr;
this.fieldIdx = fieldIdx;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.expr = this.getExpr();
builder.fieldIdx = this.getFieldIdx();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected ResolvedExpr expr = null;
protected Long fieldIdx = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
public Builder setExpr(ResolvedExpr v) {
this.expr = v;
Preconditions.checkNotNull(v, "expr must not be null");
return this;
}
public Builder setFieldIdx(long v) {
this.fieldIdx = v;
return this;
}
@Override
public final ResolvedGetStructField build() {
validate();
return new ResolvedGetStructField(
type,
expr,
fieldIdx);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
expr != null, "expr must be set");
Preconditions.checkArgument(
fieldIdx != null, "fieldIdx must be set");
}
}
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;
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();
}
ResolvedGetProtoField(
Type type,
ResolvedExpr expr,
ZetaSQLFieldDescriptor fieldDescriptor,
Value defaultValue,
boolean getHasBit,
FieldFormat.Format format,
boolean returnDefaultValueWhenUnset) {
super(
type);
this.expr = expr;
this.fieldDescriptor = fieldDescriptor;
this.defaultValue = defaultValue;
this.getHasBit = getHasBit;
this.format = format;
this.returnDefaultValueWhenUnset = returnDefaultValueWhenUnset;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.expr = this.getExpr();
builder.fieldDescriptor = this.getFieldDescriptor();
builder.defaultValue = this.getDefaultValue();
builder.getHasBit = this.getGetHasBit();
builder.format = this.getFormat();
builder.returnDefaultValueWhenUnset = this.getReturnDefaultValueWhenUnset();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected ResolvedExpr expr = null;
protected ZetaSQLFieldDescriptor fieldDescriptor = null;
protected Value defaultValue = null;
protected Boolean getHasBit = null;
protected FieldFormat.Format format = null;
protected Boolean returnDefaultValueWhenUnset = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
public Builder setExpr(ResolvedExpr v) {
this.expr = v;
Preconditions.checkNotNull(v, "expr must not be null");
return this;
}
/**
* 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 Builder setFieldDescriptor(ZetaSQLFieldDescriptor v) {
this.fieldDescriptor = v;
Preconditions.checkNotNull(v, "fieldDescriptor must not be null");
return this;
}
/**
* 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 Builder setDefaultValue(Value v) {
this.defaultValue = v;
Preconditions.checkNotNull(v, "defaultValue must not be null");
return this;
}
/**
* 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 Builder setGetHasBit(boolean v) {
this.getHasBit = v;
return this;
}
/**
* 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 Builder setFormat(FieldFormat.Format v) {
this.format = v;
Preconditions.checkNotNull(v, "format must not be null");
return this;
}
/**
* 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 Builder setReturnDefaultValueWhenUnset(boolean v) {
this.returnDefaultValueWhenUnset = v;
return this;
}
@Override
public final ResolvedGetProtoField build() {
validate();
return new ResolvedGetProtoField(
type,
expr,
fieldDescriptor,
defaultValue,
getHasBit,
format,
returnDefaultValueWhenUnset);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
expr != null, "expr must be set");
Preconditions.checkArgument(
fieldDescriptor != null, "fieldDescriptor must be set");
Preconditions.checkArgument(
defaultValue != null, "defaultValue must be set");
Preconditions.checkArgument(
getHasBit != null, "getHasBit must be set");
Preconditions.checkArgument(
format != null, "format must be set");
Preconditions.checkArgument(
returnDefaultValueWhenUnset != null, "returnDefaultValueWhenUnset must be set");
}
}
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;
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();
}
ResolvedReplaceFieldItem(
ResolvedExpr expr,
ImmutableList structIndexPath,
ImmutableList protoFieldPath) {
super();
this.expr = expr;
this.structIndexPath = structIndexPath;
this.protoFieldPath = protoFieldPath;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.expr = this.getExpr();
builder.structIndexPath = this.getStructIndexPath();
builder.protoFieldPath = this.getProtoFieldPath();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedArgument.Builder {
protected ResolvedExpr expr = null;
protected ImmutableList structIndexPath = null;
protected ImmutableList protoFieldPath = null;
private Builder() {}
/**
* 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 Builder setExpr(ResolvedExpr v) {
this.expr = v;
Preconditions.checkNotNull(v, "expr must not be null");
return this;
}
/**
* 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 Builder setStructIndexPath(List v) {
this.structIndexPath = ImmutableList.copyOf(v);
return this;
}
/**
* 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 Builder setProtoFieldPath(List v) {
this.protoFieldPath = ImmutableList.copyOf(v);
return this;
}
@Override
public final ResolvedReplaceFieldItem build() {
validate();
return new ResolvedReplaceFieldItem(
expr,
structIndexPath,
protoFieldPath);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
expr != null, "expr must be set");
Preconditions.checkArgument(
structIndexPath != null, "structIndexPath must be set");
Preconditions.checkArgument(
protoFieldPath != null, "protoFieldPath must be set");
}
}
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;
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();
}
ResolvedReplaceField(
Type type,
ResolvedExpr expr,
ImmutableList replaceFieldItemList) {
super(
type);
this.expr = expr;
this.replaceFieldItemList = replaceFieldItemList;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.expr = this.getExpr();
builder.replaceFieldItemList = this.getReplaceFieldItemList();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected ResolvedExpr expr = null;
protected ImmutableList replaceFieldItemList = null;
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
/**
* The proto/struct to modify.
*/ public Builder setExpr(ResolvedExpr v) {
this.expr = v;
Preconditions.checkNotNull(v, "expr must not be null");
return this;
}
/**
* 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 Builder setReplaceFieldItemList(List v) {
this.replaceFieldItemList = ImmutableList.copyOf(v);
return this;
}
@Override
public final ResolvedReplaceField build() {
validate();
return new ResolvedReplaceField(
type,
expr,
replaceFieldItemList);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
expr != null, "expr must be set");
Preconditions.checkArgument(
replaceFieldItemList != null, "replaceFieldItemList must be set");
}
}
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;
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();
}
ResolvedSubqueryExpr(
Type type,
SubqueryType subqueryType,
ImmutableList parameterList,
ResolvedExpr inExpr,
ResolvedScan subquery,
ImmutableList hintList) {
super(
type);
this.subqueryType = subqueryType;
this.parameterList = parameterList;
this.inExpr = inExpr;
this.subquery = subquery;
this.hintList = hintList;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.type = this.getType();
builder.subqueryType = this.getSubqueryType();
builder.parameterList = this.getParameterList();
builder.inExpr = this.getInExpr();
builder.subquery = this.getSubquery();
builder.hintList = this.getHintList();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedExpr.Builder {
protected SubqueryType subqueryType = null;
protected ImmutableList parameterList = null;
protected ResolvedExpr inExpr = null;
protected ResolvedScan subquery = null;
protected ImmutableList hintList = ImmutableList.of();
private Builder() {}
@Override
public Builder setType(Type v) {
super.setType(v);
return this;
}
public Builder setSubqueryType(SubqueryType v) {
this.subqueryType = v;
Preconditions.checkNotNull(v, "subqueryType must not be null");
return this;
}
public Builder setParameterList(List v) {
this.parameterList = ImmutableList.copyOf(v);
return this;
}
/**
* Field is only populated for subquery of type IN.
*/ public Builder setInExpr(ResolvedExpr v) {
this.inExpr = v;
Preconditions.checkNotNull(v, "inExpr must not be null");
return this;
}
public Builder setSubquery(ResolvedScan v) {
this.subquery = v;
Preconditions.checkNotNull(v, "subquery must not be null");
return this;
}
/**
* Note: Hints currently happen only for EXISTS or IN subquery but
* not for ARRAY or SCALAR subquery.
*/ public Builder setHintList(List v) {
this.hintList = ImmutableList.copyOf(v);
return this;
}
@Override
public final ResolvedSubqueryExpr build() {
validate();
return new ResolvedSubqueryExpr(
type,
subqueryType,
parameterList,
inExpr,
subquery,
hintList);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
subqueryType != null, "subqueryType must be set");
Preconditions.checkArgument(
parameterList != null, "parameterList must be set");
Preconditions.checkArgument(
inExpr != null, "inExpr must be set");
Preconditions.checkArgument(
subquery != null, "subquery must be set");
}
}
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;
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();
}
ResolvedScan(
ImmutableList columnList,
ImmutableList hintList,
boolean isOrdered) {
super();
this.columnList = columnList;
this.hintList = hintList;
this.isOrdered = isOrdered;
}
@Override
public abstract Builder toBuilder();
public static abstract class Builder extends ResolvedNode.Builder {
protected ImmutableList columnList = null;
protected ImmutableList hintList = ImmutableList.of();
protected boolean isOrdered = false;
private Builder() {}
public Builder setColumnList(List v) {
this.columnList = ImmutableList.copyOf(v);
return this;
}
public Builder setHintList(List v) {
this.hintList = ImmutableList.copyOf(v);
return this;
}
public Builder setIsOrdered(boolean v) {
this.isOrdered = v;
return this;
}
@Override
public abstract ResolvedScan build();
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
columnList != null, "columnList must be set");
}
}
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;
ResolvedModel(ResolvedModelProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
model = helper.deserialize(proto.getModel());
}
ResolvedModel(
Model model) {
super();
this.model = model;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.model = this.getModel();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedArgument.Builder {
protected Model model = null;
private Builder() {}
public Builder setModel(Model v) {
this.model = v;
Preconditions.checkNotNull(v, "model must not be null");
return this;
}
@Override
public final ResolvedModel build() {
validate();
return new ResolvedModel(
model);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
model != null, "model must be set");
}
}
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)));
}
}
}
/**
* Represents a connection object as a TVF argument.
* is the connection object encapsulated metadata to connect to
* an external data source.
*/
public static final class ResolvedConnection extends ResolvedArgument {
private final Connection connection;
ResolvedConnection(ResolvedConnectionProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
connection = helper.deserialize(proto.getConnection());
}
ResolvedConnection(
Connection connection) {
super();
this.connection = connection;
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.connection = this.getConnection();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedArgument.Builder {
protected Connection connection = null;
private Builder() {}
public Builder setConnection(Connection v) {
this.connection = v;
Preconditions.checkNotNull(v, "connection must not be null");
return this;
}
@Override
public final ResolvedConnection build() {
validate();
return new ResolvedConnection(
connection);
}
@Override
protected void validate() {
super.validate();
Preconditions.checkArgument(
connection != null, "connection must be set");
}
}
public static final ResolvedConnection deserialize(
ResolvedConnectionProto proto, DeserializationHelper helper) {
return new ResolvedConnection(proto, helper);
}
@Override
public final ResolvedNodeKind nodeKind() {
return ResolvedNodeKind.RESOLVED_CONNECTION;
}
@Override
public final String nodeKindString() {
return "Connection";
}
/**
* 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();
ResolvedConnectionProto.Builder childBuilder = ResolvedConnectionProto.newBuilder();
serialize(fileDescriptorSetsBuilder, childBuilder);
builder.setResolvedConnectionNode(childBuilder.build());
}
/**
* Serializes this node into the given {@link ResolvedConnectionProto.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,
ResolvedConnectionProto.Builder proto) {
proto.clear();
// Serialize superclass state to the parent field of the proto.
ResolvedArgumentProto parent =
(ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder);
proto.setParent(parent);
// connection is a leaf type that requires a helper method to serialize.
// (see scalar types in (broken link).py for more information.)
if (this.getConnection() != null) {
proto.setConnection(
ResolvedNodes.serialize(this.getConnection(),
fileDescriptorSetsBuilder));
}
}
public final Connection getConnection() {
return connection;
}
@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("connection", DebugStrings.toStringImpl(connection)));
}
}
}
/**
* 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 {
ResolvedSingleRowScan(ResolvedSingleRowScanProto proto, DeserializationHelper helper) {
super(proto.getParent(), helper);
}
ResolvedSingleRowScan(
ImmutableList columnList,
ImmutableList hintList,
boolean isOrdered) {
super(
columnList,
hintList,
isOrdered);
}
@Override
public Builder toBuilder() {
Builder builder = builder();
builder.columnList = this.getColumnList();
builder.hintList = this.getHintList();
builder.isOrdered = this.getIsOrdered();
return builder;
}
public static Builder builder() {
return new Builder();
}
public static final class Builder extends ResolvedScan.Builder {
private Builder() {}
@Override
public Builder setColumnList(List v) {
super.setColumnList(v);
return this;
}
@Override
public Builder setHintList(List v) {
super.setHintList(v);
return this;
}
@Override
public Builder setIsOrdered(boolean v) {
super.setIsOrdered(v);
return this;
}
@Override
public final ResolvedSingleRowScan build() {
validate();
return new ResolvedSingleRowScan(
columnList,
hintList,
isOrdered);
}
@Override
protected void validate() {
super.validate();
}
}
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
*