All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.zetasql.resolvedast.ResolvedNodes Maven / Gradle / Ivy

There is a newer version: 2024.11.1
Show newest version
/*
 * Copyright 2019 ZetaSQL Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

// ResolvedNodes.java GENERATED FROM ResolvedNodes.java.template
package com.google.zetasql.resolvedast;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.Descriptors.OneofDescriptor;
import com.google.protobuf.Message;
import com.google.protobuf.ProtocolMessageEnum;
import com.google.zetasql.AnyResolvedNodeProto;
import com.google.zetasql.Constant;
import com.google.zetasql.ConstantRefProto;
import com.google.zetasql.FieldDescriptorRefProto;
import com.google.zetasql.FileDescriptorSetsBuilder;
import com.google.zetasql.Function;
import com.google.zetasql.OneofDescriptorRefProto;
import com.google.zetasql.ResolvedFunctionCallInfo;
import com.google.zetasql.FunctionProtos.ResolvedFunctionCallInfoProto;
import com.google.zetasql.FunctionProtos.FunctionSignatureProto;
import com.google.zetasql.FunctionProtos.TVFSignatureProto;
import com.google.zetasql.FunctionRefProto;
import com.google.zetasql.FunctionSignature;
import com.google.zetasql.ZetaSQLDescriptorPool.ZetaSQLFieldDescriptor;
import com.google.zetasql.ZetaSQLResolvedNodeKind.ResolvedNodeKind;
import com.google.zetasql.ZetaSQLStrings;
import com.google.zetasql.ZetaSQLType.ProtoTypeProto;
import com.google.zetasql.ZetaSQLType.TypeProto;
import com.google.zetasql.Model;
import com.google.zetasql.ModelRefProto;
import com.google.zetasql.Procedure;
import com.google.zetasql.ProcedureRefProto;
import com.google.zetasql.ResolvedColumnProto;
import com.google.zetasql.ResolvedNodeProto;
import com.google.zetasql.Table;
import com.google.zetasql.TableRefProto;
import com.google.zetasql.TableValuedFunction;
import com.google.zetasql.TableValuedFunctionRefProto;
import com.google.zetasql.TVFSignature;
import com.google.zetasql.Type;
import com.google.zetasql.TypeAnnotationProto.FieldFormat;
import com.google.zetasql.Value;
import com.google.zetasql.ValueWithTypeProto;
import com.google.zetasql.resolvedast.ResolvedColumn;
import com.google.zetasql.resolvedast.ResolvedAggregateHavingModifierEnums.HavingModifierKind;
import com.google.zetasql.resolvedast.ResolvedOrderByItemEnums.NullOrderMode;
import com.google.zetasql.resolvedast.ResolvedStatementEnums.ObjectAccess;
import com.google.zetasql.resolvedast.ResolvedMergeWhenEnums.MatchType;
import com.google.zetasql.resolvedast.ResolvedMergeWhenEnums.ActionType;
import com.google.zetasql.resolvedast.ResolvedWindowFrameEnums.FrameUnit;
import com.google.zetasql.resolvedast.ResolvedInsertStmtEnums.InsertMode;
import com.google.zetasql.resolvedast.ResolvedImportStmtEnums.ImportKind;
import com.google.zetasql.resolvedast.ResolvedWindowFrameExprEnums.BoundaryType;
import com.google.zetasql.resolvedast.ResolvedFunctionCallBaseEnums.ErrorMode;
import com.google.zetasql.resolvedast.ResolvedBeginStmtEnums.ReadWriteMode;
import com.google.zetasql.resolvedast.ResolvedSubqueryExprEnums.SubqueryType;
import com.google.zetasql.resolvedast.ResolvedNonScalarFunctionCallBaseEnums.NullHandlingModifier;
import com.google.zetasql.resolvedast.ResolvedForeignKeyEnums.MatchMode;
import com.google.zetasql.resolvedast.ResolvedForeignKeyEnums.ActionOperation;
import com.google.zetasql.resolvedast.ResolvedArgumentDefEnums.ArgumentKind;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.CreateScope;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.CreateMode;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.SqlSecurity;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.DeterminismLevel;
import com.google.zetasql.resolvedast.ResolvedSampleScanEnums.SampleUnit;
import com.google.zetasql.resolvedast.ResolvedSetOperationScanEnums.SetOperationType;
import com.google.zetasql.resolvedast.ResolvedJoinScanEnums.JoinType;
import com.google.zetasql.ResolvedAbortBatchStmtProto;
import com.google.zetasql.ResolvedAddColumnActionProto;
import com.google.zetasql.ResolvedAggregateFunctionCallProto;
import com.google.zetasql.ResolvedAggregateHavingModifierProto;
import com.google.zetasql.ResolvedAggregateScanProto;
import com.google.zetasql.ResolvedAggregateScanBaseProto;
import com.google.zetasql.AnyResolvedAggregateScanBaseProto;
import com.google.zetasql.ResolvedAlterActionProto;
import com.google.zetasql.AnyResolvedAlterActionProto;
import com.google.zetasql.ResolvedAlterDatabaseStmtProto;
import com.google.zetasql.ResolvedAlterMaterializedViewStmtProto;
import com.google.zetasql.ResolvedAlterObjectStmtProto;
import com.google.zetasql.AnyResolvedAlterObjectStmtProto;
import com.google.zetasql.ResolvedAlterRowAccessPolicyStmtProto;
import com.google.zetasql.ResolvedAlterTableSetOptionsStmtProto;
import com.google.zetasql.ResolvedAlterTableStmtProto;
import com.google.zetasql.ResolvedAlterViewStmtProto;
import com.google.zetasql.ResolvedAnalyticFunctionCallProto;
import com.google.zetasql.ResolvedAnalyticFunctionGroupProto;
import com.google.zetasql.ResolvedAnalyticScanProto;
import com.google.zetasql.ResolvedArgumentProto;
import com.google.zetasql.AnyResolvedArgumentProto;
import com.google.zetasql.ResolvedArgumentDefProto;
import com.google.zetasql.ResolvedArgumentListProto;
import com.google.zetasql.ResolvedArgumentRefProto;
import com.google.zetasql.ResolvedArrayScanProto;
import com.google.zetasql.ResolvedAssertRowsModifiedProto;
import com.google.zetasql.ResolvedAssertStmtProto;
import com.google.zetasql.ResolvedBeginStmtProto;
import com.google.zetasql.ResolvedCallStmtProto;
import com.google.zetasql.ResolvedCastProto;
import com.google.zetasql.ResolvedCheckConstraintProto;
import com.google.zetasql.ResolvedColumnAnnotationsProto;
import com.google.zetasql.ResolvedColumnDefinitionProto;
import com.google.zetasql.ResolvedColumnHolderProto;
import com.google.zetasql.ResolvedColumnRefProto;
import com.google.zetasql.ResolvedCommitStmtProto;
import com.google.zetasql.ResolvedComputedColumnProto;
import com.google.zetasql.ResolvedConstantProto;
import com.google.zetasql.ResolvedCreateConstantStmtProto;
import com.google.zetasql.ResolvedCreateDatabaseStmtProto;
import com.google.zetasql.ResolvedCreateExternalTableStmtProto;
import com.google.zetasql.ResolvedCreateFunctionStmtProto;
import com.google.zetasql.ResolvedCreateIndexStmtProto;
import com.google.zetasql.ResolvedCreateMaterializedViewStmtProto;
import com.google.zetasql.ResolvedCreateModelStmtProto;
import com.google.zetasql.ResolvedCreateProcedureStmtProto;
import com.google.zetasql.ResolvedCreateRowAccessPolicyStmtProto;
import com.google.zetasql.ResolvedCreateStatementProto;
import com.google.zetasql.AnyResolvedCreateStatementProto;
import com.google.zetasql.ResolvedCreateTableAsSelectStmtProto;
import com.google.zetasql.ResolvedCreateTableFunctionStmtProto;
import com.google.zetasql.ResolvedCreateTableStmtProto;
import com.google.zetasql.ResolvedCreateTableStmtBaseProto;
import com.google.zetasql.AnyResolvedCreateTableStmtBaseProto;
import com.google.zetasql.ResolvedCreateViewBaseProto;
import com.google.zetasql.AnyResolvedCreateViewBaseProto;
import com.google.zetasql.ResolvedCreateViewStmtProto;
import com.google.zetasql.ResolvedDMLDefaultProto;
import com.google.zetasql.ResolvedDMLValueProto;
import com.google.zetasql.ResolvedDefineTableStmtProto;
import com.google.zetasql.ResolvedDeleteStmtProto;
import com.google.zetasql.ResolvedDescribeStmtProto;
import com.google.zetasql.ResolvedDropColumnActionProto;
import com.google.zetasql.ResolvedDropFunctionStmtProto;
import com.google.zetasql.ResolvedDropMaterializedViewStmtProto;
import com.google.zetasql.ResolvedDropRowAccessPolicyStmtProto;
import com.google.zetasql.ResolvedDropStmtProto;
import com.google.zetasql.ResolvedExplainStmtProto;
import com.google.zetasql.ResolvedExportDataStmtProto;
import com.google.zetasql.ResolvedExprProto;
import com.google.zetasql.AnyResolvedExprProto;
import com.google.zetasql.ResolvedExpressionColumnProto;
import com.google.zetasql.ResolvedFilterScanProto;
import com.google.zetasql.ResolvedFilterUsingActionProto;
import com.google.zetasql.ResolvedForeignKeyProto;
import com.google.zetasql.ResolvedFunctionCallProto;
import com.google.zetasql.ResolvedFunctionCallBaseProto;
import com.google.zetasql.AnyResolvedFunctionCallBaseProto;
import com.google.zetasql.ResolvedFunctionSignatureHolderProto;
import com.google.zetasql.ResolvedGeneratedColumnInfoProto;
import com.google.zetasql.ResolvedGetProtoFieldProto;
import com.google.zetasql.ResolvedGetStructFieldProto;
import com.google.zetasql.ResolvedGrantOrRevokeStmtProto;
import com.google.zetasql.AnyResolvedGrantOrRevokeStmtProto;
import com.google.zetasql.ResolvedGrantStmtProto;
import com.google.zetasql.ResolvedGrantToActionProto;
import com.google.zetasql.ResolvedGroupingSetProto;
import com.google.zetasql.ResolvedImportStmtProto;
import com.google.zetasql.ResolvedIndexItemProto;
import com.google.zetasql.ResolvedInsertRowProto;
import com.google.zetasql.ResolvedInsertStmtProto;
import com.google.zetasql.ResolvedJoinScanProto;
import com.google.zetasql.ResolvedLimitOffsetScanProto;
import com.google.zetasql.ResolvedLiteralProto;
import com.google.zetasql.ResolvedMakeProtoProto;
import com.google.zetasql.ResolvedMakeProtoFieldProto;
import com.google.zetasql.ResolvedMakeStructProto;
import com.google.zetasql.ResolvedMergeStmtProto;
import com.google.zetasql.ResolvedMergeWhenProto;
import com.google.zetasql.ResolvedModelProto;
import com.google.zetasql.ResolvedModuleStmtProto;
import com.google.zetasql.ResolvedNonScalarFunctionCallBaseProto;
import com.google.zetasql.AnyResolvedNonScalarFunctionCallBaseProto;
import com.google.zetasql.ResolvedOptionProto;
import com.google.zetasql.ResolvedOrderByItemProto;
import com.google.zetasql.ResolvedOrderByScanProto;
import com.google.zetasql.ResolvedOutputColumnProto;
import com.google.zetasql.ResolvedParameterProto;
import com.google.zetasql.ResolvedPrimaryKeyProto;
import com.google.zetasql.ResolvedPrivilegeProto;
import com.google.zetasql.ResolvedProjectScanProto;
import com.google.zetasql.ResolvedQueryStmtProto;
import com.google.zetasql.ResolvedRelationArgumentScanProto;
import com.google.zetasql.ResolvedRenameStmtProto;
import com.google.zetasql.ResolvedRenameToActionProto;
import com.google.zetasql.ResolvedReplaceFieldProto;
import com.google.zetasql.ResolvedReplaceFieldItemProto;
import com.google.zetasql.ResolvedRevokeFromActionProto;
import com.google.zetasql.ResolvedRevokeStmtProto;
import com.google.zetasql.ResolvedRollbackStmtProto;
import com.google.zetasql.ResolvedRunBatchStmtProto;
import com.google.zetasql.ResolvedSampleScanProto;
import com.google.zetasql.ResolvedScanProto;
import com.google.zetasql.AnyResolvedScanProto;
import com.google.zetasql.ResolvedSetOperationItemProto;
import com.google.zetasql.ResolvedSetOperationScanProto;
import com.google.zetasql.ResolvedSetOptionsActionProto;
import com.google.zetasql.ResolvedSetTransactionStmtProto;
import com.google.zetasql.ResolvedShowStmtProto;
import com.google.zetasql.ResolvedSingleRowScanProto;
import com.google.zetasql.ResolvedStartBatchStmtProto;
import com.google.zetasql.ResolvedStatementProto;
import com.google.zetasql.AnyResolvedStatementProto;
import com.google.zetasql.ResolvedSubqueryExprProto;
import com.google.zetasql.ResolvedSystemVariableProto;
import com.google.zetasql.ResolvedTVFArgumentProto;
import com.google.zetasql.ResolvedTVFScanProto;
import com.google.zetasql.ResolvedTableScanProto;
import com.google.zetasql.ResolvedTruncateStmtProto;
import com.google.zetasql.ResolvedUnnestItemProto;
import com.google.zetasql.ResolvedUpdateArrayItemProto;
import com.google.zetasql.ResolvedUpdateItemProto;
import com.google.zetasql.ResolvedUpdateStmtProto;
import com.google.zetasql.ResolvedWindowFrameProto;
import com.google.zetasql.ResolvedWindowFrameExprProto;
import com.google.zetasql.ResolvedWindowOrderingProto;
import com.google.zetasql.ResolvedWindowPartitioningProto;
import com.google.zetasql.ResolvedWithEntryProto;
import com.google.zetasql.ResolvedWithRefScanProto;
import com.google.zetasql.ResolvedWithScanProto;
import java.util.List;

/**
 * This class is a container for all subclasses of {@link ResolvedNode}.
 *
 * HTML documentation for the class hierarchy is generated in resolved_ast.html.
 * A viewable copy is available at (broken link).
 *
 * 

In this hierarchy, classes are either abstract or leaves. */ public final class ResolvedNodes { private ResolvedNodes() {} static ConstantRefProto serialize(Constant constant, @SuppressWarnings("unused") FileDescriptorSetsBuilder unused) { return ConstantRefProto.newBuilder().setName(constant.getFullName()).build(); } static FunctionRefProto serialize(Function function, @SuppressWarnings("unused") FileDescriptorSetsBuilder unused) { return FunctionRefProto.newBuilder().setName(function.getFullName()).build(); } static FunctionSignatureProto serialize(FunctionSignature functionSignature, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return functionSignature.serialize(fileDescriptorSetsBuilder); } static FieldDescriptorRefProto serialize(ZetaSQLFieldDescriptor descriptor, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { FieldDescriptorRefProto.Builder fieldDescriptorRef = FieldDescriptorRefProto.newBuilder(); ProtoTypeProto.Builder proto = ProtoTypeProto.newBuilder(); FieldDescriptor fieldDescriptor = descriptor.getDescriptor(); proto.setProtoName(fieldDescriptor.getContainingType().getFullName()); proto.setProtoFileName(fieldDescriptor.getFile().getName()); proto.setFileDescriptorSetIndex( fileDescriptorSetsBuilder.getOrAddFileDescriptorIndex( fieldDescriptor.getFile(), descriptor.getZetaSQLDescriptorPool())); fieldDescriptorRef.setContainingProto(proto.build()); fieldDescriptorRef.setNumber(fieldDescriptor.getNumber()); return fieldDescriptorRef.build(); } // TODO: Handle serialization of ResolvedFunctionCallInfos. static ResolvedFunctionCallInfoProto serialize( ResolvedFunctionCallInfo functionCallContext, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return ResolvedFunctionCallInfoProto.getDefaultInstance(); } // TODO: Handle serialization of TVFSignatures. static TVFSignatureProto serialize( TVFSignature tvfSignature, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return TVFSignatureProto.getDefaultInstance(); } // TODO: Handle serialization of TVFs. static TableValuedFunctionRefProto serialize( TableValuedFunction tvf, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return TableValuedFunctionRefProto.getDefaultInstance(); } static ModelRefProto serialize(Model model, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return ModelRefProto.newBuilder().setName(model.getName()).setSerializationId(model.getId()).build(); } static ProcedureRefProto serialize(Procedure procedure, @SuppressWarnings("unused") FileDescriptorSetsBuilder unused) { return ProcedureRefProto.newBuilder().setName(procedure.getFullName()).build(); } static TableRefProto serialize(Table table, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return TableRefProto.newBuilder().setName(table.getName()).setSerializationId(table.getId()).build(); } static TypeProto serialize(Type type, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { TypeProto.Builder builder = TypeProto.newBuilder(); type.serialize(builder, fileDescriptorSetsBuilder); return builder.build(); } static ValueWithTypeProto serialize(Value value, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ValueWithTypeProto.Builder builder = ValueWithTypeProto.newBuilder(); if (value.isValid()) { builder.setType(serialize(value.getType(), fileDescriptorSetsBuilder)); builder.setValue(value.getProto()); } return builder.build(); } static ResolvedColumnProto serialize(ResolvedColumn col, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedColumnProto.Builder builder = ResolvedColumnProto.newBuilder(); builder.setColumnId(col.getId()); builder.setTableName(col.getTableName()); builder.setName(col.getName()); builder.setType(serialize(col.getType(), fileDescriptorSetsBuilder)); return builder.build(); } public static ResolvedNode deserialize( AnyResolvedNodeProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_ARGUMENT_NODE: return ResolvedArgument.deserialize(proto.getResolvedArgumentNode(), helper); case RESOLVED_EXPR_NODE: return ResolvedExpr.deserialize(proto.getResolvedExprNode(), helper); case RESOLVED_SCAN_NODE: return ResolvedScan.deserialize(proto.getResolvedScanNode(), helper); case RESOLVED_STATEMENT_NODE: return ResolvedStatement.deserialize(proto.getResolvedStatementNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } public static AnyResolvedNodeProto serialize( ResolvedArgument node, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedNodeProto.Builder proto = AnyResolvedNodeProto.newBuilder(); AnyResolvedArgumentProto.Builder builder = AnyResolvedArgumentProto.newBuilder(); node.serialize(fileDescriptorSetsBuilder, builder); proto.setResolvedArgumentNode(builder.build()); return proto.build(); } public static AnyResolvedNodeProto serialize( ResolvedExpr node, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedNodeProto.Builder proto = AnyResolvedNodeProto.newBuilder(); AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); node.serialize(fileDescriptorSetsBuilder, builder); proto.setResolvedExprNode(builder.build()); return proto.build(); } public static AnyResolvedNodeProto serialize( ResolvedScan node, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedNodeProto.Builder proto = AnyResolvedNodeProto.newBuilder(); AnyResolvedScanProto.Builder builder = AnyResolvedScanProto.newBuilder(); node.serialize(fileDescriptorSetsBuilder, builder); proto.setResolvedScanNode(builder.build()); return proto.build(); } public static AnyResolvedNodeProto serialize( ResolvedStatement node, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedNodeProto.Builder proto = AnyResolvedNodeProto.newBuilder(); AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); node.serialize(fileDescriptorSetsBuilder, builder); proto.setResolvedStatementNode(builder.build()); return proto.build(); } /** * A visitor that ResolvedNodes accepts. The default implementation of each * method is to descend into the AST graph and redispatch to each child node. * Clients are expected to override {@code visit} methods corresponding * to the types they are interested in. */ public static abstract class Visitor { protected void defaultVisit(ResolvedNode node) { node.acceptChildren(this); } // private helper method to visit a list of nodes private void descend(ImmutableList children) { children.stream().forEach((child) -> child.accept(this)); } // private helper method to check for null before visiting a node private void descend(ResolvedNode child) { if (child != null) { child.accept(this); } } public void visit(ResolvedLiteral node) { defaultVisit(node); } public void visit(ResolvedParameter node) { defaultVisit(node); } public void visit(ResolvedExpressionColumn node) { defaultVisit(node); } public void visit(ResolvedColumnRef node) { defaultVisit(node); } public void visit(ResolvedConstant node) { defaultVisit(node); } public void visit(ResolvedSystemVariable node) { defaultVisit(node); } public void visit(ResolvedFunctionCall node) { defaultVisit(node); } public void visit(ResolvedAggregateFunctionCall node) { defaultVisit(node); } public void visit(ResolvedAnalyticFunctionCall node) { defaultVisit(node); } public void visit(ResolvedCast node) { defaultVisit(node); } public void visit(ResolvedMakeStruct node) { defaultVisit(node); } public void visit(ResolvedMakeProto node) { defaultVisit(node); } public void visit(ResolvedMakeProtoField node) { defaultVisit(node); } public void visit(ResolvedGetStructField node) { defaultVisit(node); } public void visit(ResolvedGetProtoField node) { defaultVisit(node); } public void visit(ResolvedReplaceFieldItem node) { defaultVisit(node); } public void visit(ResolvedReplaceField node) { defaultVisit(node); } public void visit(ResolvedSubqueryExpr node) { defaultVisit(node); } public void visit(ResolvedModel node) { defaultVisit(node); } public void visit(ResolvedSingleRowScan node) { defaultVisit(node); } public void visit(ResolvedTableScan node) { defaultVisit(node); } public void visit(ResolvedJoinScan node) { defaultVisit(node); } public void visit(ResolvedArrayScan node) { defaultVisit(node); } public void visit(ResolvedColumnHolder node) { defaultVisit(node); } public void visit(ResolvedFilterScan node) { defaultVisit(node); } public void visit(ResolvedGroupingSet node) { defaultVisit(node); } public void visit(ResolvedAggregateScan node) { defaultVisit(node); } public void visit(ResolvedSetOperationItem node) { defaultVisit(node); } public void visit(ResolvedSetOperationScan node) { defaultVisit(node); } public void visit(ResolvedOrderByScan node) { defaultVisit(node); } public void visit(ResolvedLimitOffsetScan node) { defaultVisit(node); } public void visit(ResolvedWithRefScan node) { defaultVisit(node); } public void visit(ResolvedAnalyticScan node) { defaultVisit(node); } public void visit(ResolvedSampleScan node) { defaultVisit(node); } public void visit(ResolvedComputedColumn node) { defaultVisit(node); } public void visit(ResolvedOrderByItem node) { defaultVisit(node); } public void visit(ResolvedColumnAnnotations node) { defaultVisit(node); } public void visit(ResolvedGeneratedColumnInfo node) { defaultVisit(node); } public void visit(ResolvedColumnDefinition node) { defaultVisit(node); } public void visit(ResolvedPrimaryKey node) { defaultVisit(node); } public void visit(ResolvedForeignKey node) { defaultVisit(node); } public void visit(ResolvedCheckConstraint node) { defaultVisit(node); } public void visit(ResolvedOutputColumn node) { defaultVisit(node); } public void visit(ResolvedProjectScan node) { defaultVisit(node); } public void visit(ResolvedTVFScan node) { defaultVisit(node); } public void visit(ResolvedTVFArgument node) { defaultVisit(node); } public void visit(ResolvedExplainStmt node) { defaultVisit(node); } public void visit(ResolvedQueryStmt node) { defaultVisit(node); } public void visit(ResolvedCreateDatabaseStmt node) { defaultVisit(node); } public void visit(ResolvedIndexItem node) { defaultVisit(node); } public void visit(ResolvedUnnestItem node) { defaultVisit(node); } public void visit(ResolvedCreateIndexStmt node) { defaultVisit(node); } public void visit(ResolvedCreateTableStmt node) { defaultVisit(node); } public void visit(ResolvedCreateTableAsSelectStmt node) { defaultVisit(node); } public void visit(ResolvedCreateModelStmt node) { defaultVisit(node); } public void visit(ResolvedCreateViewStmt node) { defaultVisit(node); } public void visit(ResolvedCreateExternalTableStmt node) { defaultVisit(node); } public void visit(ResolvedExportDataStmt node) { defaultVisit(node); } public void visit(ResolvedDefineTableStmt node) { defaultVisit(node); } public void visit(ResolvedDescribeStmt node) { defaultVisit(node); } public void visit(ResolvedShowStmt node) { defaultVisit(node); } public void visit(ResolvedBeginStmt node) { defaultVisit(node); } public void visit(ResolvedSetTransactionStmt node) { defaultVisit(node); } public void visit(ResolvedCommitStmt node) { defaultVisit(node); } public void visit(ResolvedRollbackStmt node) { defaultVisit(node); } public void visit(ResolvedStartBatchStmt node) { defaultVisit(node); } public void visit(ResolvedRunBatchStmt node) { defaultVisit(node); } public void visit(ResolvedAbortBatchStmt node) { defaultVisit(node); } public void visit(ResolvedDropStmt node) { defaultVisit(node); } public void visit(ResolvedDropMaterializedViewStmt node) { defaultVisit(node); } public void visit(ResolvedWithScan node) { defaultVisit(node); } public void visit(ResolvedWithEntry node) { defaultVisit(node); } public void visit(ResolvedOption node) { defaultVisit(node); } public void visit(ResolvedWindowPartitioning node) { defaultVisit(node); } public void visit(ResolvedWindowOrdering node) { defaultVisit(node); } public void visit(ResolvedWindowFrame node) { defaultVisit(node); } public void visit(ResolvedAnalyticFunctionGroup node) { defaultVisit(node); } public void visit(ResolvedWindowFrameExpr node) { defaultVisit(node); } public void visit(ResolvedDMLValue node) { defaultVisit(node); } public void visit(ResolvedDMLDefault node) { defaultVisit(node); } public void visit(ResolvedAssertStmt node) { defaultVisit(node); } public void visit(ResolvedAssertRowsModified node) { defaultVisit(node); } public void visit(ResolvedInsertRow node) { defaultVisit(node); } public void visit(ResolvedInsertStmt node) { defaultVisit(node); } public void visit(ResolvedDeleteStmt node) { defaultVisit(node); } public void visit(ResolvedUpdateItem node) { defaultVisit(node); } public void visit(ResolvedUpdateArrayItem node) { defaultVisit(node); } public void visit(ResolvedUpdateStmt node) { defaultVisit(node); } public void visit(ResolvedMergeWhen node) { defaultVisit(node); } public void visit(ResolvedMergeStmt node) { defaultVisit(node); } public void visit(ResolvedTruncateStmt node) { defaultVisit(node); } public void visit(ResolvedPrivilege node) { defaultVisit(node); } public void visit(ResolvedGrantStmt node) { defaultVisit(node); } public void visit(ResolvedRevokeStmt node) { defaultVisit(node); } public void visit(ResolvedAlterDatabaseStmt node) { defaultVisit(node); } public void visit(ResolvedAlterMaterializedViewStmt node) { defaultVisit(node); } public void visit(ResolvedAlterTableStmt node) { defaultVisit(node); } public void visit(ResolvedAlterViewStmt node) { defaultVisit(node); } public void visit(ResolvedSetOptionsAction node) { defaultVisit(node); } public void visit(ResolvedAddColumnAction node) { defaultVisit(node); } public void visit(ResolvedDropColumnAction node) { defaultVisit(node); } public void visit(ResolvedAlterTableSetOptionsStmt node) { defaultVisit(node); } public void visit(ResolvedRenameStmt node) { defaultVisit(node); } public void visit(ResolvedCreateRowAccessPolicyStmt node) { defaultVisit(node); } public void visit(ResolvedDropRowAccessPolicyStmt node) { defaultVisit(node); } public void visit(ResolvedGrantToAction node) { defaultVisit(node); } public void visit(ResolvedFilterUsingAction node) { defaultVisit(node); } public void visit(ResolvedRevokeFromAction node) { defaultVisit(node); } public void visit(ResolvedRenameToAction node) { defaultVisit(node); } public void visit(ResolvedAlterRowAccessPolicyStmt node) { defaultVisit(node); } public void visit(ResolvedCreateConstantStmt node) { defaultVisit(node); } public void visit(ResolvedCreateFunctionStmt node) { defaultVisit(node); } public void visit(ResolvedArgumentDef node) { defaultVisit(node); } public void visit(ResolvedArgumentRef node) { defaultVisit(node); } public void visit(ResolvedCreateTableFunctionStmt node) { defaultVisit(node); } public void visit(ResolvedRelationArgumentScan node) { defaultVisit(node); } public void visit(ResolvedArgumentList node) { defaultVisit(node); } public void visit(ResolvedFunctionSignatureHolder node) { defaultVisit(node); } public void visit(ResolvedDropFunctionStmt node) { defaultVisit(node); } public void visit(ResolvedCallStmt node) { defaultVisit(node); } public void visit(ResolvedImportStmt node) { defaultVisit(node); } public void visit(ResolvedModuleStmt node) { defaultVisit(node); } public void visit(ResolvedAggregateHavingModifier node) { defaultVisit(node); } public void visit(ResolvedCreateMaterializedViewStmt node) { defaultVisit(node); } public void visit(ResolvedCreateProcedureStmt node) { defaultVisit(node); } } /** * Argument nodes are not self-contained nodes in the tree. They exist * only to describe parameters to another node (e.g. columns in an OrderBy). * This node is here for organizational purposes only, to cluster these * argument nodes. */ public static abstract class ResolvedArgument extends ResolvedNode { protected ResolvedArgument(ResolvedArgumentProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static ResolvedArgument deserialize( AnyResolvedArgumentProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_MAKE_PROTO_FIELD_NODE: return ResolvedMakeProtoField.deserialize( proto.getResolvedMakeProtoFieldNode(), helper); case RESOLVED_COLUMN_HOLDER_NODE: return ResolvedColumnHolder.deserialize( proto.getResolvedColumnHolderNode(), helper); case RESOLVED_COMPUTED_COLUMN_NODE: return ResolvedComputedColumn.deserialize( proto.getResolvedComputedColumnNode(), helper); case RESOLVED_ORDER_BY_ITEM_NODE: return ResolvedOrderByItem.deserialize( proto.getResolvedOrderByItemNode(), helper); case RESOLVED_OUTPUT_COLUMN_NODE: return ResolvedOutputColumn.deserialize( proto.getResolvedOutputColumnNode(), helper); case RESOLVED_WITH_ENTRY_NODE: return ResolvedWithEntry.deserialize( proto.getResolvedWithEntryNode(), helper); case RESOLVED_OPTION_NODE: return ResolvedOption.deserialize( proto.getResolvedOptionNode(), helper); case RESOLVED_WINDOW_PARTITIONING_NODE: return ResolvedWindowPartitioning.deserialize( proto.getResolvedWindowPartitioningNode(), helper); case RESOLVED_WINDOW_ORDERING_NODE: return ResolvedWindowOrdering.deserialize( proto.getResolvedWindowOrderingNode(), helper); case RESOLVED_WINDOW_FRAME_NODE: return ResolvedWindowFrame.deserialize( proto.getResolvedWindowFrameNode(), helper); case RESOLVED_ANALYTIC_FUNCTION_GROUP_NODE: return ResolvedAnalyticFunctionGroup.deserialize( proto.getResolvedAnalyticFunctionGroupNode(), helper); case RESOLVED_WINDOW_FRAME_EXPR_NODE: return ResolvedWindowFrameExpr.deserialize( proto.getResolvedWindowFrameExprNode(), helper); case RESOLVED_DMLVALUE_NODE: return ResolvedDMLValue.deserialize( proto.getResolvedDmlvalueNode(), helper); case RESOLVED_ASSERT_ROWS_MODIFIED_NODE: return ResolvedAssertRowsModified.deserialize( proto.getResolvedAssertRowsModifiedNode(), helper); case RESOLVED_INSERT_ROW_NODE: return ResolvedInsertRow.deserialize( proto.getResolvedInsertRowNode(), helper); case RESOLVED_UPDATE_ITEM_NODE: return ResolvedUpdateItem.deserialize( proto.getResolvedUpdateItemNode(), helper); case RESOLVED_PRIVILEGE_NODE: return ResolvedPrivilege.deserialize( proto.getResolvedPrivilegeNode(), helper); case RESOLVED_ARGUMENT_DEF_NODE: return ResolvedArgumentDef.deserialize( proto.getResolvedArgumentDefNode(), helper); case RESOLVED_ARGUMENT_LIST_NODE: return ResolvedArgumentList.deserialize( proto.getResolvedArgumentListNode(), helper); case RESOLVED_TVFARGUMENT_NODE: return ResolvedTVFArgument.deserialize( proto.getResolvedTvfargumentNode(), helper); case RESOLVED_FUNCTION_SIGNATURE_HOLDER_NODE: return ResolvedFunctionSignatureHolder.deserialize( proto.getResolvedFunctionSignatureHolderNode(), helper); case RESOLVED_AGGREGATE_HAVING_MODIFIER_NODE: return ResolvedAggregateHavingModifier.deserialize( proto.getResolvedAggregateHavingModifierNode(), helper); case RESOLVED_COLUMN_DEFINITION_NODE: return ResolvedColumnDefinition.deserialize( proto.getResolvedColumnDefinitionNode(), helper); case RESOLVED_PRIMARY_KEY_NODE: return ResolvedPrimaryKey.deserialize( proto.getResolvedPrimaryKeyNode(), helper); case RESOLVED_GROUPING_SET_NODE: return ResolvedGroupingSet.deserialize( proto.getResolvedGroupingSetNode(), helper); case RESOLVED_SET_OPERATION_ITEM_NODE: return ResolvedSetOperationItem.deserialize( proto.getResolvedSetOperationItemNode(), helper); case RESOLVED_INDEX_ITEM_NODE: return ResolvedIndexItem.deserialize( proto.getResolvedIndexItemNode(), helper); case RESOLVED_MERGE_WHEN_NODE: return ResolvedMergeWhen.deserialize( proto.getResolvedMergeWhenNode(), helper); case RESOLVED_UPDATE_ARRAY_ITEM_NODE: return ResolvedUpdateArrayItem.deserialize( proto.getResolvedUpdateArrayItemNode(), helper); case RESOLVED_COLUMN_ANNOTATIONS_NODE: return ResolvedColumnAnnotations.deserialize( proto.getResolvedColumnAnnotationsNode(), helper); case RESOLVED_GENERATED_COLUMN_INFO_NODE: return ResolvedGeneratedColumnInfo.deserialize( proto.getResolvedGeneratedColumnInfoNode(), helper); case RESOLVED_MODEL_NODE: return ResolvedModel.deserialize( proto.getResolvedModelNode(), helper); case RESOLVED_FOREIGN_KEY_NODE: return ResolvedForeignKey.deserialize( proto.getResolvedForeignKeyNode(), helper); case RESOLVED_CHECK_CONSTRAINT_NODE: return ResolvedCheckConstraint.deserialize( proto.getResolvedCheckConstraintNode(), helper); case RESOLVED_ALTER_ACTION_NODE: return ResolvedAlterAction.deserialize( proto.getResolvedAlterActionNode(), helper); case RESOLVED_UNNEST_ITEM_NODE: return ResolvedUnnestItem.deserialize( proto.getResolvedUnnestItemNode(), helper); case RESOLVED_REPLACE_FIELD_ITEM_NODE: return ResolvedReplaceFieldItem.deserialize( proto.getResolvedReplaceFieldItemNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedArgumentProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedArgumentProto.Builder builder = ResolvedArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedNodeProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedNodeProto.Builder builder) { builder.clear(); AnyResolvedArgumentProto.Builder childBuilder = AnyResolvedArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedArgumentNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedArgumentProto.Builder}) for its parent proto container type. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public abstract void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedArgumentProto.Builder builder); /** * Serializes this node into the given {@link ResolvedArgumentProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedArgumentProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedNodeProto parent = (ResolvedNodeProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } public static abstract class ResolvedExpr extends ResolvedNode { private final Type type; protected ResolvedExpr(ResolvedExprProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); type = helper.deserialize(proto.getType()); } public static ResolvedExpr deserialize( AnyResolvedExprProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_LITERAL_NODE: return ResolvedLiteral.deserialize( proto.getResolvedLiteralNode(), helper); case RESOLVED_PARAMETER_NODE: return ResolvedParameter.deserialize( proto.getResolvedParameterNode(), helper); case RESOLVED_EXPRESSION_COLUMN_NODE: return ResolvedExpressionColumn.deserialize( proto.getResolvedExpressionColumnNode(), helper); case RESOLVED_COLUMN_REF_NODE: return ResolvedColumnRef.deserialize( proto.getResolvedColumnRefNode(), helper); case RESOLVED_FUNCTION_CALL_BASE_NODE: return ResolvedFunctionCallBase.deserialize( proto.getResolvedFunctionCallBaseNode(), helper); case RESOLVED_CAST_NODE: return ResolvedCast.deserialize( proto.getResolvedCastNode(), helper); case RESOLVED_MAKE_STRUCT_NODE: return ResolvedMakeStruct.deserialize( proto.getResolvedMakeStructNode(), helper); case RESOLVED_MAKE_PROTO_NODE: return ResolvedMakeProto.deserialize( proto.getResolvedMakeProtoNode(), helper); case RESOLVED_GET_STRUCT_FIELD_NODE: return ResolvedGetStructField.deserialize( proto.getResolvedGetStructFieldNode(), helper); case RESOLVED_GET_PROTO_FIELD_NODE: return ResolvedGetProtoField.deserialize( proto.getResolvedGetProtoFieldNode(), helper); case RESOLVED_SUBQUERY_EXPR_NODE: return ResolvedSubqueryExpr.deserialize( proto.getResolvedSubqueryExprNode(), helper); case RESOLVED_DMLDEFAULT_NODE: return ResolvedDMLDefault.deserialize( proto.getResolvedDmldefaultNode(), helper); case RESOLVED_ARGUMENT_REF_NODE: return ResolvedArgumentRef.deserialize( proto.getResolvedArgumentRefNode(), helper); case RESOLVED_CONSTANT_NODE: return ResolvedConstant.deserialize( proto.getResolvedConstantNode(), helper); case RESOLVED_REPLACE_FIELD_NODE: return ResolvedReplaceField.deserialize( proto.getResolvedReplaceFieldNode(), helper); case RESOLVED_SYSTEM_VARIABLE_NODE: return ResolvedSystemVariable.deserialize( proto.getResolvedSystemVariableNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedExprProto.Builder builder = ResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedNodeProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedNodeProto.Builder builder) { builder.clear(); AnyResolvedExprProto.Builder childBuilder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExprNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedExprProto.Builder}) for its parent proto container type. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public abstract void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder); /** * Serializes this node into the given {@link ResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedExprProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedNodeProto parent = (ResolvedNodeProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // type is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getType() != null) { proto.setType( ResolvedNodes.serialize(this.getType(), fileDescriptorSetsBuilder)); } } public final Type getType() { return type; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(type)) { fields.add(new DebugStringField("type", DebugStrings.toStringImpl(type))); } } } /** * Any literal value, including NULL literals. * There is a special-cased constructor here that gets the type from the * Value. */ public static final class ResolvedLiteral extends ResolvedExpr { private final Value value; /** * If true, then the literal is explicitly typed and cannot be used * for literal coercions. * *

This exists mainly for resolver bookkeeping and should be ignored * by engines. */ private final boolean hasExplicitType; /** * Distinct ID of the literal, if it is a floating point value, * within the resolved AST. When coercing from floating point * to NUMERIC, the resolver uses the float_literal_id to find the * original image of the literal to avoid precision loss. An ID of 0 * represents a literal without a cached image. */ private final long floatLiteralId; protected ResolvedLiteral(ResolvedLiteralProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); value = helper.deserialize(proto.getValue()); hasExplicitType = proto.getHasExplicitType(); floatLiteralId = proto.getFloatLiteralId(); } public static final ResolvedLiteral deserialize( ResolvedLiteralProto proto, DeserializationHelper helper) { return new ResolvedLiteral(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_LITERAL; } @Override public final String nodeKindString() { return "Literal"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedLiteralProto.Builder childBuilder = ResolvedLiteralProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedLiteralNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedLiteralProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedLiteralProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // value is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getValue() != null) { proto.setValue( ResolvedNodes.serialize(this.getValue(), fileDescriptorSetsBuilder)); } // hasExplicitType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setHasExplicitType(this.getHasExplicitType()); // floatLiteralId is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setFloatLiteralId(this.getFloatLiteralId()); } public final Value getValue() { return value; } /** * If true, then the literal is explicitly typed and cannot be used * for literal coercions. * *

This exists mainly for resolver bookkeeping and should be ignored * by engines. */ public final boolean getHasExplicitType() { return hasExplicitType; } /** * Distinct ID of the literal, if it is a floating point value, * within the resolved AST. When coercing from floating point * to NUMERIC, the resolver uses the float_literal_id to find the * original image of the literal to avoid precision loss. An ID of 0 * represents a literal without a cached image. */ public final long getFloatLiteralId() { return floatLiteralId; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("value", DebugStrings.toStringImpl(value))); } if (!DebugStrings.isDefaultValue(hasExplicitType)) { fields.add(new DebugStringField("has_explicit_type", DebugStrings.toStringImpl(hasExplicitType))); } if (!DebugStrings.isDefaultValue(floatLiteralId)) { fields.add(new DebugStringField("float_literal_id", DebugStrings.toStringImpl(floatLiteralId))); } } } public static final class ResolvedParameter extends ResolvedExpr { /** * If non-empty, the name of the parameter. * *

A ResolvedParameter will have either a name or a position but not * both. */ private final String name; /** * If non-zero, the 1-based position of the positional parameter. * *

A ResolvedParameter will have either a name or a position but not * both. */ private final long position; /** * If true, then the parameter has no specified type. * *

This exists mainly for resolver bookkeeping and should be ignored * by engines. */ private final boolean isUntyped; protected ResolvedParameter(ResolvedParameterProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); position = proto.getPosition(); isUntyped = proto.getIsUntyped(); } public static final ResolvedParameter deserialize( ResolvedParameterProto proto, DeserializationHelper helper) { return new ResolvedParameter(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PARAMETER; } @Override public final String nodeKindString() { return "Parameter"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedParameterProto.Builder childBuilder = ResolvedParameterProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedParameterNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedParameterProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedParameterProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // name is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setName(this.getName()); // position is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setPosition(this.getPosition()); // isUntyped is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsUntyped(this.getIsUntyped()); } /** * If non-empty, the name of the parameter. * *

A ResolvedParameter will have either a name or a position but not * both. */ public final String getName() { return name; } /** * If non-zero, the 1-based position of the positional parameter. * *

A ResolvedParameter will have either a name or a position but not * both. */ public final long getPosition() { return position; } /** * If true, then the parameter has no specified type. * *

This exists mainly for resolver bookkeeping and should be ignored * by engines. */ public final boolean getIsUntyped() { return isUntyped; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(name)) { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (!DebugStrings.isDefaultValue(position)) { fields.add(new DebugStringField("position", DebugStrings.toStringImpl(position))); } if (!DebugStrings.isDefaultValue(isUntyped)) { fields.add(new DebugStringField("is_untyped", DebugStrings.toStringImpl(isUntyped))); } } } /** * This represents a column when analyzing a standalone expression. * This is only used when the analyzer was called using AnalyzeExpression. * Expression column names and types come from * AnalyzerOptions::AddExpressionColumn. * will always be in lowercase. */ public static final class ResolvedExpressionColumn extends ResolvedExpr { private final String name; protected ResolvedExpressionColumn(ResolvedExpressionColumnProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); } public static final ResolvedExpressionColumn deserialize( ResolvedExpressionColumnProto proto, DeserializationHelper helper) { return new ResolvedExpressionColumn(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXPRESSION_COLUMN; } @Override public final String nodeKindString() { return "ExpressionColumn"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedExpressionColumnProto.Builder childBuilder = ResolvedExpressionColumnProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExpressionColumnNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExpressionColumnProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedExpressionColumnProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // name is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setName(this.getName()); } public final String getName() { return name; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } } } /** * An expression referencing the value of some column visible in the * current Scan node. * *

If is false, this must be a column visible in the Scan * containing this expression, either because it was produced inside that * Scan or it is on the of some child of this Scan. * *

If is true, this references a column from outside a * subquery that is visible as a correlated column inside. * The column referenced here must show up on the parameters list for the * subquery. See ResolvedSubqueryExpr. */ public static final class ResolvedColumnRef extends ResolvedExpr { private final ResolvedColumn column; private final boolean isCorrelated; protected ResolvedColumnRef(ResolvedColumnRefProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); column = helper.deserialize(proto.getColumn()); isCorrelated = proto.getIsCorrelated(); } public static final ResolvedColumnRef deserialize( ResolvedColumnRefProto proto, DeserializationHelper helper) { return new ResolvedColumnRef(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_COLUMN_REF; } @Override public final String nodeKindString() { return "ColumnRef"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedColumnRefProto.Builder childBuilder = ResolvedColumnRefProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedColumnRefNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedColumnRefProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedColumnRefProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // column is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getColumn() != null) { proto.setColumn( ResolvedNodes.serialize(this.getColumn(), fileDescriptorSetsBuilder)); } // isCorrelated is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsCorrelated(this.getIsCorrelated()); } public final ResolvedColumn getColumn() { return column; } public final boolean getIsCorrelated() { return isCorrelated; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("column", DebugStrings.toStringImpl(column))); } if (!DebugStrings.isDefaultValue(isCorrelated)) { fields.add(new DebugStringField("is_correlated", DebugStrings.toStringImpl(isCorrelated))); } } } /** * A reference to a named constant. */ public static final class ResolvedConstant extends ResolvedExpr { /** * The matching Constant from the Catalog. */ private final Constant constant; protected ResolvedConstant(ResolvedConstantProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); constant = helper.deserialize(proto.getConstant()); } public static final ResolvedConstant deserialize( ResolvedConstantProto proto, DeserializationHelper helper) { return new ResolvedConstant(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CONSTANT; } @Override public final String nodeKindString() { return "Constant"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedConstantProto.Builder childBuilder = ResolvedConstantProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedConstantNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedConstantProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedConstantProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // constant is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getConstant() != null) { proto.setConstant( ResolvedNodes.serialize(this.getConstant(), fileDescriptorSetsBuilder)); } } /** * The matching Constant from the Catalog. */ public final Constant getConstant() { return constant; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } protected String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * A reference to a system variable. */ public static final class ResolvedSystemVariable extends ResolvedExpr { /** * Path to system variable. */ private final ImmutableList namePath; protected ResolvedSystemVariable(ResolvedSystemVariableProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); } public static final ResolvedSystemVariable deserialize( ResolvedSystemVariableProto proto, DeserializationHelper helper) { return new ResolvedSystemVariable(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SYSTEM_VARIABLE; } @Override public final String nodeKindString() { return "SystemVariable"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedSystemVariableProto.Builder childBuilder = ResolvedSystemVariableProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSystemVariableNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSystemVariableProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedSystemVariableProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // namePath is a collection of leaf types that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.addAllNamePath(this.getNamePath()); } /** * Path to system variable. */ public final ImmutableList getNamePath() { return namePath; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } protected String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * Common base class for scalar and aggregate function calls. */ public static abstract class ResolvedFunctionCallBase extends ResolvedExpr { /** * The matching Function from the Catalog. */ private final Function function; /** * The concrete FunctionSignature reflecting the matching Function * signature and the function's resolved input . * The function has the mode AGGREGATE iff it is an aggregate * function, in which case this node must be either * ResolvedAggregateFunctionCall or ResolvedAnalyticFunctionCall. */ private final FunctionSignature signature; private final ImmutableList argumentList; /** * If error_mode=SAFE_ERROR_MODE, and if this function call returns a * semantic error (based on input data, not transient server * problems), return NULL instead of an error. This is used for * functions called using SAFE, as in SAFE.FUNCTION(...). */ private final ErrorMode errorMode; protected ResolvedFunctionCallBase(ResolvedFunctionCallBaseProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); function = helper.deserialize(proto.getFunction()); signature = helper.deserialize(proto.getSignature()); ImmutableList.Builder argumentListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getArgumentListList()) { argumentListBuilder .add(ResolvedExpr.deserialize(element, helper)); } argumentList = argumentListBuilder.build(); errorMode = proto.getErrorMode(); } public static ResolvedFunctionCallBase deserialize( AnyResolvedFunctionCallBaseProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_FUNCTION_CALL_NODE: return ResolvedFunctionCall.deserialize( proto.getResolvedFunctionCallNode(), helper); case RESOLVED_NON_SCALAR_FUNCTION_CALL_BASE_NODE: return ResolvedNonScalarFunctionCallBase.deserialize( proto.getResolvedNonScalarFunctionCallBaseNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedFunctionCallBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedFunctionCallBaseProto.Builder builder = ResolvedFunctionCallBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); AnyResolvedFunctionCallBaseProto.Builder childBuilder = AnyResolvedFunctionCallBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFunctionCallBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedFunctionCallBaseProto.Builder}) for its parent proto container type. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public abstract void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedFunctionCallBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedFunctionCallBaseProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedFunctionCallBaseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // function is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getFunction() != null) { proto.setFunction( ResolvedNodes.serialize(this.getFunction(), fileDescriptorSetsBuilder)); } // signature is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getSignature() != null) { proto.setSignature( ResolvedNodes.serialize(this.getSignature(), fileDescriptorSetsBuilder)); } // argumentList is a collection of AST nodes. Serialize each of them. ImmutableList argumentLists = this.getArgumentList(); for (ResolvedExpr element : argumentLists) { AnyResolvedExprProto.Builder argumentListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, argumentListBuilder); proto.addArgumentList(argumentListBuilder.build()); } // errorMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setErrorMode(this.getErrorMode()); } /** * The matching Function from the Catalog. */ public final Function getFunction() { return function; } /** * The concrete FunctionSignature reflecting the matching Function * signature and the function's resolved input . * The function has the mode AGGREGATE iff it is an aggregate * function, in which case this node must be either * ResolvedAggregateFunctionCall or ResolvedAnalyticFunctionCall. */ public final FunctionSignature getSignature() { return signature; } public final ImmutableList getArgumentList() { return argumentList; } /** * If error_mode=SAFE_ERROR_MODE, and if this function call returns a * semantic error (based on input data, not transient server * problems), return NULL instead of an error. This is used for * functions called using SAFE, as in SAFE.FUNCTION(...). */ public final ErrorMode getErrorMode() { return errorMode; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(argumentList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } protected String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * A regular function call. The signature will always have mode SCALAR. * Most scalar expressions show up as FunctionCalls using builtin signatures. */ public static final class ResolvedFunctionCall extends ResolvedFunctionCallBase { /** * This contains optional custom information about a particular * function call. * *

If some Function subclass requires computing additional * information at resolving time, that extra information can be * stored as a subclass of ResolvedFunctionCallInfo here. * For example, TemplatedSQLFunction stores the resolved template * body here as a TemplatedSQLFunctionCall. * *

This field is ignorable because for most types of function calls, * there is no extra information to consider besides the arguments * and other fields from ResolvedFunctionCallBase. */ private final ResolvedFunctionCallInfo functionCallInfo; protected ResolvedFunctionCall(ResolvedFunctionCallProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); functionCallInfo = helper.deserialize(proto.getFunctionCallInfo()); } public static final ResolvedFunctionCall deserialize( ResolvedFunctionCallProto proto, DeserializationHelper helper) { return new ResolvedFunctionCall(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FUNCTION_CALL; } @Override public final String nodeKindString() { return "FunctionCall"; } /** * Serializes this node into a {@link AnyResolvedFunctionCallBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedFunctionCallBaseProto.Builder builder = AnyResolvedFunctionCallBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedFunctionCallBaseProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedFunctionCallBaseProto.Builder builder) { builder.clear(); ResolvedFunctionCallProto.Builder childBuilder = ResolvedFunctionCallProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFunctionCallNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedFunctionCallProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedFunctionCallProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedFunctionCallBaseProto parent = (ResolvedFunctionCallBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // functionCallInfo is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getFunctionCallInfo() != null) { proto.setFunctionCallInfo( ResolvedNodes.serialize(this.getFunctionCallInfo(), fileDescriptorSetsBuilder)); } } /** * This contains optional custom information about a particular * function call. * *

If some Function subclass requires computing additional * information at resolving time, that extra information can be * stored as a subclass of ResolvedFunctionCallInfo here. * For example, TemplatedSQLFunction stores the resolved template * body here as a TemplatedSQLFunctionCall. * *

This field is ignorable because for most types of function calls, * there is no extra information to consider besides the arguments * and other fields from ResolvedFunctionCallBase. */ public final ResolvedFunctionCallInfo getFunctionCallInfo() { return functionCallInfo; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(functionCallInfo)) { fields.add(new DebugStringField("function_call_info", DebugStrings.toStringImpl(functionCallInfo))); } } } /** * Common base class for scalar and aggregate function calls. */ public static abstract class ResolvedNonScalarFunctionCallBase extends ResolvedFunctionCallBase { /** * Apply DISTINCT to the stream of input values before calling * function. */ private final boolean distinct; /** * Apply IGNORE/RESPECT NULLS filtering to the stream of input * values. */ private final NullHandlingModifier nullHandlingModifier; protected ResolvedNonScalarFunctionCallBase(ResolvedNonScalarFunctionCallBaseProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); distinct = proto.getDistinct(); nullHandlingModifier = proto.getNullHandlingModifier(); } public static ResolvedNonScalarFunctionCallBase deserialize( AnyResolvedNonScalarFunctionCallBaseProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_AGGREGATE_FUNCTION_CALL_NODE: return ResolvedAggregateFunctionCall.deserialize( proto.getResolvedAggregateFunctionCallNode(), helper); case RESOLVED_ANALYTIC_FUNCTION_CALL_NODE: return ResolvedAnalyticFunctionCall.deserialize( proto.getResolvedAnalyticFunctionCallNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedNonScalarFunctionCallBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedNonScalarFunctionCallBaseProto.Builder builder = ResolvedNonScalarFunctionCallBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedFunctionCallBaseProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedFunctionCallBaseProto.Builder builder) { builder.clear(); AnyResolvedNonScalarFunctionCallBaseProto.Builder childBuilder = AnyResolvedNonScalarFunctionCallBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedNonScalarFunctionCallBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedNonScalarFunctionCallBaseProto.Builder}) for its parent proto container type. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public abstract void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedNonScalarFunctionCallBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedNonScalarFunctionCallBaseProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedNonScalarFunctionCallBaseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedFunctionCallBaseProto parent = (ResolvedFunctionCallBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // distinct is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setDistinct(this.getDistinct()); // nullHandlingModifier is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setNullHandlingModifier(this.getNullHandlingModifier()); } /** * Apply DISTINCT to the stream of input values before calling * function. */ public final boolean getDistinct() { return distinct; } /** * Apply IGNORE/RESPECT NULLS filtering to the stream of input * values. */ public final NullHandlingModifier getNullHandlingModifier() { return nullHandlingModifier; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(distinct)) { fields.add(new DebugStringField("distinct", DebugStrings.toStringImpl(distinct))); } if (!DebugStrings.isDefaultValue(nullHandlingModifier)) { fields.add(new DebugStringField("null_handling_modifier", DebugStrings.toStringImpl(nullHandlingModifier))); } } } /** * An aggregate function call. The signature always has mode AGGREGATE. * This node only ever shows up as the outer function call in a * ResolvedAggregateScan::aggregate_list. */ public static final class ResolvedAggregateFunctionCall extends ResolvedNonScalarFunctionCallBase { /** * Apply HAVING MAX/MIN filtering to the stream of input values. */ private final ResolvedAggregateHavingModifier havingModifier; /** * Apply ordering to the stream of input values before calling * function. */ private final ImmutableList orderByItemList; private final ResolvedExpr limit; /** * This contains optional custom information about a particular * function call. Functions may introduce subclasses of this class to * add custom information as needed on a per-function basis. * *

This field is ignorable because for most types of function calls, * there is no extra information to consider besides the arguments * and other fields from ResolvedFunctionCallBase. However, for * example, the TemplateSQLFunction in * zetasql/public/templated_sql_function.h defines the * TemplatedSQLFunctionCall subclass which includes the * fully-resolved function body in context of the actual concrete * types of the arguments provided to the function call. */ private final ResolvedFunctionCallInfo functionCallInfo; protected ResolvedAggregateFunctionCall(ResolvedAggregateFunctionCallProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasHavingModifier()) { havingModifier = ResolvedAggregateHavingModifier.deserialize(proto.getHavingModifier(), helper); } else { havingModifier = null; } ImmutableList.Builder orderByItemListBuilder = ImmutableList.builder(); for (ResolvedOrderByItemProto element : proto.getOrderByItemListList()) { orderByItemListBuilder .add(ResolvedOrderByItem.deserialize(element, helper)); } orderByItemList = orderByItemListBuilder.build(); if (proto.hasLimit()) { limit = ResolvedExpr.deserialize(proto.getLimit(), helper); } else { limit = null; } functionCallInfo = helper.deserialize(proto.getFunctionCallInfo()); } public static final ResolvedAggregateFunctionCall deserialize( ResolvedAggregateFunctionCallProto proto, DeserializationHelper helper) { return new ResolvedAggregateFunctionCall(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_AGGREGATE_FUNCTION_CALL; } @Override public final String nodeKindString() { return "AggregateFunctionCall"; } /** * Serializes this node into a {@link AnyResolvedNonScalarFunctionCallBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedNonScalarFunctionCallBaseProto.Builder builder = AnyResolvedNonScalarFunctionCallBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedNonScalarFunctionCallBaseProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedNonScalarFunctionCallBaseProto.Builder builder) { builder.clear(); ResolvedAggregateFunctionCallProto.Builder childBuilder = ResolvedAggregateFunctionCallProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAggregateFunctionCallNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAggregateFunctionCallProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedAggregateFunctionCallProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedNonScalarFunctionCallBaseProto parent = (ResolvedNonScalarFunctionCallBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // havingModifier is an AST node. Call its serialization chain. if (this.getHavingModifier() != null) { ResolvedAggregateHavingModifierProto.Builder havingModifierBuilder = ResolvedAggregateHavingModifierProto.newBuilder(); this.getHavingModifier().serialize( fileDescriptorSetsBuilder, havingModifierBuilder); proto.setHavingModifier( havingModifierBuilder.build()); } // orderByItemList is a collection of AST nodes. Serialize each of them. ImmutableList orderByItemLists = this.getOrderByItemList(); for (ResolvedOrderByItem element : orderByItemLists) { ResolvedOrderByItemProto.Builder orderByItemListBuilder = ResolvedOrderByItemProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, orderByItemListBuilder); proto.addOrderByItemList(orderByItemListBuilder.build()); } // limit is an AST node. Call its serialization chain. if (this.getLimit() != null) { AnyResolvedExprProto.Builder limitBuilder = AnyResolvedExprProto.newBuilder(); this.getLimit().serialize( fileDescriptorSetsBuilder, limitBuilder); proto.setLimit( limitBuilder.build()); } // functionCallInfo is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getFunctionCallInfo() != null) { proto.setFunctionCallInfo( ResolvedNodes.serialize(this.getFunctionCallInfo(), fileDescriptorSetsBuilder)); } } /** * Apply HAVING MAX/MIN filtering to the stream of input values. */ public final ResolvedAggregateHavingModifier getHavingModifier() { return havingModifier; } /** * Apply ordering to the stream of input values before calling * function. */ public final ImmutableList getOrderByItemList() { return orderByItemList; } public final ResolvedExpr getLimit() { return limit; } /** * This contains optional custom information about a particular * function call. Functions may introduce subclasses of this class to * add custom information as needed on a per-function basis. * *

This field is ignorable because for most types of function calls, * there is no extra information to consider besides the arguments * and other fields from ResolvedFunctionCallBase. However, for * example, the TemplateSQLFunction in * zetasql/public/templated_sql_function.h defines the * TemplatedSQLFunctionCall subclass which includes the * fully-resolved function body in context of the actual concrete * types of the arguments provided to the function call. */ public final ResolvedFunctionCallInfo getFunctionCallInfo() { return functionCallInfo; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(havingModifier); visitor.descend(orderByItemList); visitor.descend(limit); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (havingModifier != null) { fields.add(new DebugStringField("having_modifier", havingModifier)); } if (!orderByItemList.isEmpty()) { fields.add(new DebugStringField("order_by_item_list", orderByItemList)); } if (limit != null) { fields.add(new DebugStringField("limit", limit)); } if (!DebugStrings.isDefaultValue(functionCallInfo)) { fields.add(new DebugStringField("function_call_info", DebugStrings.toStringImpl(functionCallInfo))); } } } /** * An analytic function call. The mode of the function is either AGGREGATE * or ANALYTIC. This node only ever shows up as a function call in a * ResolvedAnalyticFunctionGroup::analytic_function_list. Its associated * window is not under this node but as a sibling of its parent node. * *

can be NULL. */ public static final class ResolvedAnalyticFunctionCall extends ResolvedNonScalarFunctionCallBase { private final ResolvedWindowFrame windowFrame; protected ResolvedAnalyticFunctionCall(ResolvedAnalyticFunctionCallProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasWindowFrame()) { windowFrame = ResolvedWindowFrame.deserialize(proto.getWindowFrame(), helper); } else { windowFrame = null; } } public static final ResolvedAnalyticFunctionCall deserialize( ResolvedAnalyticFunctionCallProto proto, DeserializationHelper helper) { return new ResolvedAnalyticFunctionCall(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ANALYTIC_FUNCTION_CALL; } @Override public final String nodeKindString() { return "AnalyticFunctionCall"; } /** * Serializes this node into a {@link AnyResolvedNonScalarFunctionCallBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedNonScalarFunctionCallBaseProto.Builder builder = AnyResolvedNonScalarFunctionCallBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedNonScalarFunctionCallBaseProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedNonScalarFunctionCallBaseProto.Builder builder) { builder.clear(); ResolvedAnalyticFunctionCallProto.Builder childBuilder = ResolvedAnalyticFunctionCallProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAnalyticFunctionCallNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAnalyticFunctionCallProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedAnalyticFunctionCallProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedNonScalarFunctionCallBaseProto parent = (ResolvedNonScalarFunctionCallBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // windowFrame is an AST node. Call its serialization chain. if (this.getWindowFrame() != null) { ResolvedWindowFrameProto.Builder windowFrameBuilder = ResolvedWindowFrameProto.newBuilder(); this.getWindowFrame().serialize( fileDescriptorSetsBuilder, windowFrameBuilder); proto.setWindowFrame( windowFrameBuilder.build()); } } public final ResolvedWindowFrame getWindowFrame() { return windowFrame; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(windowFrame); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (windowFrame != null) { fields.add(new DebugStringField("window_frame", windowFrame)); } } } /** * A cast expression, casting the result of an input expression to the * target Type. * *

Valid casts are defined in the CastHashMap (see cast.cc), which identifies * valid from-Type, to-Type pairs. Consumers can access it through * GetZetaSQLCasts(). */ public static final class ResolvedCast extends ResolvedExpr { private final ResolvedExpr expr; /** * Whether to return NULL if the cast fails. This is set to true for * SAFE_CAST. */ private final boolean returnNullOnError; protected ResolvedCast(ResolvedCastProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } returnNullOnError = proto.getReturnNullOnError(); } public static final ResolvedCast deserialize( ResolvedCastProto proto, DeserializationHelper helper) { return new ResolvedCast(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CAST; } @Override public final String nodeKindString() { return "Cast"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedCastProto.Builder childBuilder = ResolvedCastProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCastNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCastProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedCastProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // expr is an AST node. Call its serialization chain. if (this.getExpr() != null) { AnyResolvedExprProto.Builder exprBuilder = AnyResolvedExprProto.newBuilder(); this.getExpr().serialize( fileDescriptorSetsBuilder, exprBuilder); proto.setExpr( exprBuilder.build()); } // returnNullOnError is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setReturnNullOnError(this.getReturnNullOnError()); } public final ResolvedExpr getExpr() { return expr; } /** * Whether to return NULL if the cast fails. This is set to true for * SAFE_CAST. */ public final boolean getReturnNullOnError() { return returnNullOnError; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } protected String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * Construct a struct value. is always a StructType. * matches 1:1 with the fields in position-wise. * Each field's type will match the corresponding field in . */ public static final class ResolvedMakeStruct extends ResolvedExpr { private final ImmutableList fieldList; protected ResolvedMakeStruct(ResolvedMakeStructProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder fieldListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getFieldListList()) { fieldListBuilder .add(ResolvedExpr.deserialize(element, helper)); } fieldList = fieldListBuilder.build(); } public static final ResolvedMakeStruct deserialize( ResolvedMakeStructProto proto, DeserializationHelper helper) { return new ResolvedMakeStruct(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MAKE_STRUCT; } @Override public final String nodeKindString() { return "MakeStruct"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedMakeStructProto.Builder childBuilder = ResolvedMakeStructProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMakeStructNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMakeStructProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedMakeStructProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // fieldList is a collection of AST nodes. Serialize each of them. ImmutableList fieldLists = this.getFieldList(); for (ResolvedExpr element : fieldLists) { AnyResolvedExprProto.Builder fieldListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, fieldListBuilder); proto.addFieldList(fieldListBuilder.build()); } } public final ImmutableList getFieldList() { return fieldList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(fieldList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!fieldList.isEmpty()) { fields.add(new DebugStringField("field_list", fieldList)); } } } /** * Construct a proto value. is always a ProtoType. * is a vector of (FieldDescriptor, expr) pairs to write. * will contain all required fields, and no duplicate fields. */ public static final class ResolvedMakeProto extends ResolvedExpr { private final ImmutableList fieldList; protected ResolvedMakeProto(ResolvedMakeProtoProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder fieldListBuilder = ImmutableList.builder(); for (ResolvedMakeProtoFieldProto element : proto.getFieldListList()) { fieldListBuilder .add(ResolvedMakeProtoField.deserialize(element, helper)); } fieldList = fieldListBuilder.build(); } public static final ResolvedMakeProto deserialize( ResolvedMakeProtoProto proto, DeserializationHelper helper) { return new ResolvedMakeProto(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MAKE_PROTO; } @Override public final String nodeKindString() { return "MakeProto"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedMakeProtoProto.Builder childBuilder = ResolvedMakeProtoProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMakeProtoNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMakeProtoProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedMakeProtoProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // fieldList is a collection of AST nodes. Serialize each of them. ImmutableList fieldLists = this.getFieldList(); for (ResolvedMakeProtoField element : fieldLists) { ResolvedMakeProtoFieldProto.Builder fieldListBuilder = ResolvedMakeProtoFieldProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, fieldListBuilder); proto.addFieldList(fieldListBuilder.build()); } } public final ImmutableList getFieldList() { return fieldList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(fieldList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!fieldList.isEmpty()) { fields.add(new DebugStringField("field_list", fieldList)); } } } /** * One field assignment in a ResolvedMakeProto expression. * The type of expr will match with the zetasql type of the proto field. * The type will be an array iff the field is repeated. * *

For NULL values of , the proto field should be cleared. * *

If any value of cannot be written into the field, this query * should fail. */ public static final class ResolvedMakeProtoField extends ResolvedArgument { private final ZetaSQLFieldDescriptor fieldDescriptor; /** * Provides the Format annotation that should be used when building * this field. The annotation specifies both the ZetaSQL type and * the encoding format for this field. */ private final FieldFormat.Format format; private final ResolvedExpr expr; protected ResolvedMakeProtoField(ResolvedMakeProtoFieldProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); fieldDescriptor = helper.deserialize(proto.getFieldDescriptor()); format = proto.getFormat(); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } } public static final ResolvedMakeProtoField deserialize( ResolvedMakeProtoFieldProto proto, DeserializationHelper helper) { return new ResolvedMakeProtoField(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MAKE_PROTO_FIELD; } @Override public final String nodeKindString() { return "MakeProtoField"; } /** * Serializes this node into a {@link AnyResolvedArgumentProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedArgumentProto.Builder builder = AnyResolvedArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedArgumentProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedArgumentProto.Builder builder) { builder.clear(); ResolvedMakeProtoFieldProto.Builder childBuilder = ResolvedMakeProtoFieldProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMakeProtoFieldNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMakeProtoFieldProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedMakeProtoFieldProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // fieldDescriptor is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getFieldDescriptor() != null) { proto.setFieldDescriptor( ResolvedNodes.serialize(this.getFieldDescriptor(), fileDescriptorSetsBuilder)); } // format is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setFormat(this.getFormat()); // expr is an AST node. Call its serialization chain. if (this.getExpr() != null) { AnyResolvedExprProto.Builder exprBuilder = AnyResolvedExprProto.newBuilder(); this.getExpr().serialize( fileDescriptorSetsBuilder, exprBuilder); proto.setExpr( exprBuilder.build()); } } public final ZetaSQLFieldDescriptor getFieldDescriptor() { return fieldDescriptor; } /** * Provides the Format annotation that should be used when building * this field. The annotation specifies both the ZetaSQL type and * the encoding format for this field. */ public final FieldFormat.Format getFormat() { return format; } public final ResolvedExpr getExpr() { return expr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } protected String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * Get the field in position (0-based) from , which has a * STRUCT type. */ public static final class ResolvedGetStructField extends ResolvedExpr { private final ResolvedExpr expr; private final long fieldIdx; protected ResolvedGetStructField(ResolvedGetStructFieldProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } fieldIdx = proto.getFieldIdx(); } public static final ResolvedGetStructField deserialize( ResolvedGetStructFieldProto proto, DeserializationHelper helper) { return new ResolvedGetStructField(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GET_STRUCT_FIELD; } @Override public final String nodeKindString() { return "GetStructField"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedGetStructFieldProto.Builder childBuilder = ResolvedGetStructFieldProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGetStructFieldNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGetStructFieldProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedGetStructFieldProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // expr is an AST node. Call its serialization chain. if (this.getExpr() != null) { AnyResolvedExprProto.Builder exprBuilder = AnyResolvedExprProto.newBuilder(); this.getExpr().serialize( fileDescriptorSetsBuilder, exprBuilder); proto.setExpr( exprBuilder.build()); } // fieldIdx is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setFieldIdx(this.getFieldIdx()); } public final ResolvedExpr getExpr() { return expr; } public final long getFieldIdx() { return fieldIdx; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } { fields.add(new DebugStringField("field_idx", DebugStrings.toStringImpl(fieldIdx))); } } } public static final class ResolvedGetProtoField extends ResolvedExpr { private final ResolvedExpr expr; /** * The proto2 FieldDescriptor to extract. This provides the tag * number and wire type. Additional decoding may be necessary if any * of the other modifiers below are set. Consumers should use those * ZetaSQL-computed modifiers rather than examining field * annotations directly. * *

The field is an extension field iff * field_descriptor->is_extension() is true. NOTE: The extended * descriptor's full_name must match the 's type's full_name, * but may not be the same Descriptor. Extension FieldDescriptors may * come from a different DescriptorPool. * *

The field is required if field_descriptor->is_required(). If the * field is required and not present, an error should result. */ private final ZetaSQLFieldDescriptor fieldDescriptor; /** * Default value to use when the proto field is not set. The default * may be NULL (e.g. for proto2 fields with a use_defaults=false * annotation). * *

This will not be filled in (the Value will be uninitialized) if * get_has_bit is true, or the field is required. * *

If field_descriptor->is_required() and the field is not present, * the engine should return an error. * *

If the itself returns NULL, then extracting a field should * also return NULL, unless is * true. In that case, the default value is returned. * *

TODO Make un-ignorable after clients migrate to start * using it. */ private final Value defaultValue; /** * Indicates whether to return a bool indicating if a value was * present, rather than return the value (or NULL). Never set for * repeated fields. This field cannot be set if * is true, and vice versa. * Expression type will be BOOL. */ private final boolean getHasBit; /** * Provides the Format annotation that should be used when reading * this field. The annotation specifies both the ZetaSQL type and * the encoding format for this field. This cannot be set when * get_has_bit is true. */ private final FieldFormat.Format format; /** * Indicates that the default value should be returned if is * NULL. * *

This can only be set for non-message fields. If the field is a * proto2 field, then it must be annotated with * zetasql.use_defaults=true. This cannot be set when * is true or the field is required. */ private final boolean returnDefaultValueWhenUnset; protected ResolvedGetProtoField(ResolvedGetProtoFieldProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } fieldDescriptor = helper.deserialize(proto.getFieldDescriptor()); defaultValue = helper.deserialize(proto.getDefaultValue()); getHasBit = proto.getGetHasBit(); format = proto.getFormat(); returnDefaultValueWhenUnset = proto.getReturnDefaultValueWhenUnset(); } public static final ResolvedGetProtoField deserialize( ResolvedGetProtoFieldProto proto, DeserializationHelper helper) { return new ResolvedGetProtoField(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GET_PROTO_FIELD; } @Override public final String nodeKindString() { return "GetProtoField"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedGetProtoFieldProto.Builder childBuilder = ResolvedGetProtoFieldProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGetProtoFieldNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGetProtoFieldProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedGetProtoFieldProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // expr is an AST node. Call its serialization chain. if (this.getExpr() != null) { AnyResolvedExprProto.Builder exprBuilder = AnyResolvedExprProto.newBuilder(); this.getExpr().serialize( fileDescriptorSetsBuilder, exprBuilder); proto.setExpr( exprBuilder.build()); } // fieldDescriptor is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getFieldDescriptor() != null) { proto.setFieldDescriptor( ResolvedNodes.serialize(this.getFieldDescriptor(), fileDescriptorSetsBuilder)); } // defaultValue is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getDefaultValue() != null) { proto.setDefaultValue( ResolvedNodes.serialize(this.getDefaultValue(), fileDescriptorSetsBuilder)); } // getHasBit is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setGetHasBit(this.getGetHasBit()); // format is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setFormat(this.getFormat()); // returnDefaultValueWhenUnset is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setReturnDefaultValueWhenUnset(this.getReturnDefaultValueWhenUnset()); } public final ResolvedExpr getExpr() { return expr; } /** * The proto2 FieldDescriptor to extract. This provides the tag * number and wire type. Additional decoding may be necessary if any * of the other modifiers below are set. Consumers should use those * ZetaSQL-computed modifiers rather than examining field * annotations directly. * *

The field is an extension field iff * field_descriptor->is_extension() is true. NOTE: The extended * descriptor's full_name must match the 's type's full_name, * but may not be the same Descriptor. Extension FieldDescriptors may * come from a different DescriptorPool. * *

The field is required if field_descriptor->is_required(). If the * field is required and not present, an error should result. */ public final ZetaSQLFieldDescriptor getFieldDescriptor() { return fieldDescriptor; } /** * Default value to use when the proto field is not set. The default * may be NULL (e.g. for proto2 fields with a use_defaults=false * annotation). * *

This will not be filled in (the Value will be uninitialized) if * get_has_bit is true, or the field is required. * *

If field_descriptor->is_required() and the field is not present, * the engine should return an error. * *

If the itself returns NULL, then extracting a field should * also return NULL, unless is * true. In that case, the default value is returned. * *

TODO Make un-ignorable after clients migrate to start * using it. */ public final Value getDefaultValue() { return defaultValue; } /** * Indicates whether to return a bool indicating if a value was * present, rather than return the value (or NULL). Never set for * repeated fields. This field cannot be set if * is true, and vice versa. * Expression type will be BOOL. */ public final boolean getGetHasBit() { return getHasBit; } /** * Provides the Format annotation that should be used when reading * this field. The annotation specifies both the ZetaSQL type and * the encoding format for this field. This cannot be set when * get_has_bit is true. */ public final FieldFormat.Format getFormat() { return format; } /** * Indicates that the default value should be returned if is * NULL. * *

This can only be set for non-message fields. If the field is a * proto2 field, then it must be annotated with * zetasql.use_defaults=true. This cannot be set when * is true or the field is required. */ public final boolean getReturnDefaultValueWhenUnset() { return returnDefaultValueWhenUnset; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } { fields.add(new DebugStringField("field_descriptor", DebugStrings.toStringImpl(fieldDescriptor))); } if (!DebugStrings.isDefaultValue(defaultValue)) { fields.add(new DebugStringField("default_value", DebugStrings.toStringImpl(defaultValue))); } if (!DebugStrings.isDefaultValue(getHasBit)) { fields.add(new DebugStringField("get_has_bit", DebugStrings.toStringImpl(getHasBit))); } if (!DebugStrings.isDefaultValue(format)) { fields.add(new DebugStringField("format", DebugStrings.toStringImpl(format))); } if (!DebugStrings.isDefaultValue(returnDefaultValueWhenUnset)) { fields.add(new DebugStringField("return_default_value_when_unset", DebugStrings.toStringImpl(returnDefaultValueWhenUnset))); } } } /** * An argument to the REPLACE_FIELDS() function which specifies a field path * and a value that this field will be set to. The field path to be modified * can be constructed through the and * fields. These vectors correspond to field paths in a STRUCT and PROTO, * respectively. At least one of these vectors must be non-empty. * *

If only is non-empty, then the field path only * references top-level and nested struct fields. * *

If only is non-empty, then the field path only * references top-level and nested message fields. * *

If both and are non-empty, then the * field path should be expanded starting with . The last * field in will be the proto from which the first field * in is extracted. * *

and the field to be modified must be the same type. */ public static final class ResolvedReplaceFieldItem extends ResolvedArgument { /** * The value that the final field in will be set * to. * *

If is NULL, the field will be unset. If * is a required field, the engine must return an error if it is set * to NULL. */ private final ResolvedExpr expr; /** * A vector of integers that denotes the path to a struct field that * will be modified. The integer values in this vector correspond to * field positions (0-based) in a STRUCT. If * is also non-empty, then the field corresponding to the last index * in this vector should be of proto type. */ private final ImmutableList structIndexPath; /** * A vector of FieldDescriptors that denotes the path to a proto * field that will be modified. If is also * non-empty, then the first element in this vector should be a * subfield of the proto corresponding to the last element in * . */ private final ImmutableList protoFieldPath; protected ResolvedReplaceFieldItem(ResolvedReplaceFieldItemProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } structIndexPath = ImmutableList.copyOf(proto.getStructIndexPathList()); ImmutableList.Builder protoFieldPathBuilder = ImmutableList.builder(); for (FieldDescriptorRefProto element : proto.getProtoFieldPathList()) { protoFieldPathBuilder.add(helper.deserialize(element)); } protoFieldPath = protoFieldPathBuilder.build(); } public static final ResolvedReplaceFieldItem deserialize( ResolvedReplaceFieldItemProto proto, DeserializationHelper helper) { return new ResolvedReplaceFieldItem(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_REPLACE_FIELD_ITEM; } @Override public final String nodeKindString() { return "ReplaceFieldItem"; } /** * Serializes this node into a {@link AnyResolvedArgumentProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedArgumentProto.Builder builder = AnyResolvedArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedArgumentProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedArgumentProto.Builder builder) { builder.clear(); ResolvedReplaceFieldItemProto.Builder childBuilder = ResolvedReplaceFieldItemProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedReplaceFieldItemNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedReplaceFieldItemProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedReplaceFieldItemProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // expr is an AST node. Call its serialization chain. if (this.getExpr() != null) { AnyResolvedExprProto.Builder exprBuilder = AnyResolvedExprProto.newBuilder(); this.getExpr().serialize( fileDescriptorSetsBuilder, exprBuilder); proto.setExpr( exprBuilder.build()); } // structIndexPath is a collection of leaf types that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.addAllStructIndexPath(this.getStructIndexPath()); // protoFieldPath is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList protoFieldPaths = this.getProtoFieldPath(); for (ZetaSQLFieldDescriptor element : protoFieldPaths) { proto.addProtoFieldPath(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } } /** * The value that the final field in will be set * to. * *

If is NULL, the field will be unset. If * is a required field, the engine must return an error if it is set * to NULL. */ public final ResolvedExpr getExpr() { return expr; } /** * A vector of integers that denotes the path to a struct field that * will be modified. The integer values in this vector correspond to * field positions (0-based) in a STRUCT. If * is also non-empty, then the field corresponding to the last index * in this vector should be of proto type. */ public final ImmutableList getStructIndexPath() { return structIndexPath; } /** * A vector of FieldDescriptors that denotes the path to a proto * field that will be modified. If is also * non-empty, then the first element in this vector should be a * subfield of the proto corresponding to the last element in * . */ public final ImmutableList getProtoFieldPath() { return protoFieldPath; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } if (!DebugStrings.isDefaultValue(structIndexPath)) { fields.add(new DebugStringField("struct_index_path", DebugStrings.toStringCommaSeparatedForInt(structIndexPath))); } if (!DebugStrings.isDefaultValue(protoFieldPath)) { fields.add(new DebugStringField("proto_field_path", DebugStrings.toStringPeriodSeparatedForFieldDescriptors(protoFieldPath))); } } } /** * Represents a call to the REPLACE_FIELDS() function. This function * can be used to copy a proto or struct, modify a few fields and * output the resulting proto or struct. The SQL syntax for this * function is REPLACE_FIELDS(, ). * *

See (broken link) for more detail. */ public static final class ResolvedReplaceField extends ResolvedExpr { /** * The proto/struct to modify. */ private final ResolvedExpr expr; /** * The list of field paths to be modified along with their new * values. * *

Engines must check at evaluation time that the modifications in * obey the following rules * regarding updating protos in ZetaSQL: * - Modifying a subfield of a NULL-valued proto-valued field is an * error. * - Clearing a required field or subfield is an error. */ private final ImmutableList replaceFieldItemList; protected ResolvedReplaceField(ResolvedReplaceFieldProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } ImmutableList.Builder replaceFieldItemListBuilder = ImmutableList.builder(); for (ResolvedReplaceFieldItemProto element : proto.getReplaceFieldItemListList()) { replaceFieldItemListBuilder .add(ResolvedReplaceFieldItem.deserialize(element, helper)); } replaceFieldItemList = replaceFieldItemListBuilder.build(); } public static final ResolvedReplaceField deserialize( ResolvedReplaceFieldProto proto, DeserializationHelper helper) { return new ResolvedReplaceField(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_REPLACE_FIELD; } @Override public final String nodeKindString() { return "ReplaceField"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedReplaceFieldProto.Builder childBuilder = ResolvedReplaceFieldProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedReplaceFieldNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedReplaceFieldProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedReplaceFieldProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // expr is an AST node. Call its serialization chain. if (this.getExpr() != null) { AnyResolvedExprProto.Builder exprBuilder = AnyResolvedExprProto.newBuilder(); this.getExpr().serialize( fileDescriptorSetsBuilder, exprBuilder); proto.setExpr( exprBuilder.build()); } // replaceFieldItemList is a collection of AST nodes. Serialize each of them. ImmutableList replaceFieldItemLists = this.getReplaceFieldItemList(); for (ResolvedReplaceFieldItem element : replaceFieldItemLists) { ResolvedReplaceFieldItemProto.Builder replaceFieldItemListBuilder = ResolvedReplaceFieldItemProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, replaceFieldItemListBuilder); proto.addReplaceFieldItemList(replaceFieldItemListBuilder.build()); } } /** * The proto/struct to modify. */ public final ResolvedExpr getExpr() { return expr; } /** * The list of field paths to be modified along with their new * values. * *

Engines must check at evaluation time that the modifications in * obey the following rules * regarding updating protos in ZetaSQL: * - Modifying a subfield of a NULL-valued proto-valued field is an * error. * - Clearing a required field or subfield is an error. */ public final ImmutableList getReplaceFieldItemList() { return replaceFieldItemList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); visitor.descend(replaceFieldItemList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } if (!replaceFieldItemList.isEmpty()) { fields.add(new DebugStringField("replace_field_item_list", replaceFieldItemList)); } } } /** * A subquery in an expression (not a FROM clause). The subquery runs * in the context of a single input row and produces a single output value. * *

Correlated subqueries can be thought of like functions, with a parameter * list. The gives the set of ResolvedColumns from outside * the subquery that are used inside. * *

Inside the subquery, the only allowed references to values outside the * subquery are to the named ColumnRefs listed in . * Any reference to one of these parameters will be represented as a * ResolvedColumnRef with set to true. * *

These parameters are only visible through one level of expression * subquery. An expression subquery inside an expression has to list * parameters again if parameters from the outer query are passed down * further. (This does not apply for table subqueries inside an expression * subquery. Table subqueries are never indicated in the resolved AST, so * Scan nodes inside an expression query may have come from a nested table * subquery, and they can still reference the expression subquery's * parameters.) * *

An empty means that the subquery is uncorrelated. It is * permissable to run an uncorrelated subquery only once and reuse the result. * TODO Do we want to specify semantics more firmly here? * *

The semantics vary based on SubqueryType: * SCALAR * Usage: ( ) * If the subquery produces zero rows, the output value is NULL. * If the subquery produces exactly one row, that row is the output value. * If the subquery produces more than one row, raise a runtime error. * * ARRAY * Usage: ARRAY( ) * The subquery produces an array value with zero or more rows, with * one array element per subquery row produced. * * EXISTS * Usage: EXISTS( ) * The output type is always bool. The result is true if the subquery * produces at least one row, and false otherwise. * * IN * Usage: [NOT] IN ( ) * The output type is always bool. The result is true when is * equal to at least one row, and false otherwise. The row * contains only one column, and the types of and the * subquery column must exactly match a built-in signature for the * '$equals' comparison function (they must be the same type or one * must be INT64 and the other UINT64). NOT will be expressed as a $not * FunctionCall wrapping this SubqueryExpr. * *

The subquery for a SCALAR or ARRAY or IN subquery must have exactly one * output column. * The output type for a SCALAR or ARRAY subquery is that column's type or * an array of that column's type. (The subquery scan may include a Project * with a MakeStruct or MakeProto expression to construct a single value * from multiple columns.) */ public static final class ResolvedSubqueryExpr extends ResolvedExpr { private final SubqueryType subqueryType; private final ImmutableList parameterList; /** * Field is only populated for subquery of type IN. */ private final ResolvedExpr inExpr; private final ResolvedScan subquery; /** * Note: Hints currently happen only for EXISTS or IN subquery but * not for ARRAY or SCALAR subquery. */ private final ImmutableList hintList; protected ResolvedSubqueryExpr(ResolvedSubqueryExprProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); subqueryType = proto.getSubqueryType(); ImmutableList.Builder parameterListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getParameterListList()) { parameterListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } parameterList = parameterListBuilder.build(); if (proto.hasInExpr()) { inExpr = ResolvedExpr.deserialize(proto.getInExpr(), helper); } else { inExpr = null; } if (proto.hasSubquery()) { subquery = ResolvedScan.deserialize(proto.getSubquery(), helper); } else { subquery = null; } ImmutableList.Builder hintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getHintListList()) { hintListBuilder .add(ResolvedOption.deserialize(element, helper)); } hintList = hintListBuilder.build(); } public static final ResolvedSubqueryExpr deserialize( ResolvedSubqueryExprProto proto, DeserializationHelper helper) { return new ResolvedSubqueryExpr(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SUBQUERY_EXPR; } @Override public final String nodeKindString() { return "SubqueryExpr"; } /** * Serializes this node into a {@link AnyResolvedExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedExprProto.Builder builder = AnyResolvedExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedExprProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedExprProto.Builder builder) { builder.clear(); ResolvedSubqueryExprProto.Builder childBuilder = ResolvedSubqueryExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSubqueryExprNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSubqueryExprProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedSubqueryExprProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // subqueryType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setSubqueryType(this.getSubqueryType()); // parameterList is a collection of AST nodes. Serialize each of them. ImmutableList parameterLists = this.getParameterList(); for (ResolvedColumnRef element : parameterLists) { ResolvedColumnRefProto.Builder parameterListBuilder = ResolvedColumnRefProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, parameterListBuilder); proto.addParameterList(parameterListBuilder.build()); } // inExpr is an AST node. Call its serialization chain. if (this.getInExpr() != null) { AnyResolvedExprProto.Builder inExprBuilder = AnyResolvedExprProto.newBuilder(); this.getInExpr().serialize( fileDescriptorSetsBuilder, inExprBuilder); proto.setInExpr( inExprBuilder.build()); } // subquery is an AST node. Call its serialization chain. if (this.getSubquery() != null) { AnyResolvedScanProto.Builder subqueryBuilder = AnyResolvedScanProto.newBuilder(); this.getSubquery().serialize( fileDescriptorSetsBuilder, subqueryBuilder); proto.setSubquery( subqueryBuilder.build()); } // hintList is a collection of AST nodes. Serialize each of them. ImmutableList hintLists = this.getHintList(); for (ResolvedOption element : hintLists) { ResolvedOptionProto.Builder hintListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, hintListBuilder); proto.addHintList(hintListBuilder.build()); } } public final SubqueryType getSubqueryType() { return subqueryType; } public final ImmutableList getParameterList() { return parameterList; } /** * Field is only populated for subquery of type IN. */ public final ResolvedExpr getInExpr() { return inExpr; } public final ResolvedScan getSubquery() { return subquery; } /** * Note: Hints currently happen only for EXISTS or IN subquery but * not for ARRAY or SCALAR subquery. */ public final ImmutableList getHintList() { return hintList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(parameterList); visitor.descend(inExpr); visitor.descend(subquery); visitor.descend(hintList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("subquery_type", DebugStrings.toStringImpl(subqueryType))); } if (!parameterList.isEmpty()) { fields.add(new DebugStringField("parameter_list", parameterList)); } if (inExpr != null) { fields.add(new DebugStringField("in_expr", inExpr)); } if (subquery != null) { fields.add(new DebugStringField("subquery", subquery)); } if (!hintList.isEmpty()) { fields.add(new DebugStringField("hint_list", hintList)); } } } /** * Common superclass for all Scans, which are nodes that produce rows * (e.g. scans, joins, table subqueries). A query's FROM clause is * represented as a single Scan that composes all input sources into * a single row stream. * *

Each Scan has a that says what columns are produced. * The Scan logically produces a stream of output rows, where each row * has exactly these columns. * *

Each Scan may have an attached , storing each hint as * a ResolvedOption. * *

If is true, this Scan produces an ordered output, either * by generating order itself (OrderByScan) or by preserving the order * of its single input scan (LimitOffsetScan, ProjectScan, or WithScan). */ public static abstract class ResolvedScan extends ResolvedNode { private final ImmutableList columnList; private final ImmutableList hintList; private final boolean isOrdered; protected ResolvedScan(ResolvedScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder columnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getColumnListList()) { columnListBuilder.add(helper.deserialize(element)); } columnList = columnListBuilder.build(); ImmutableList.Builder hintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getHintListList()) { hintListBuilder .add(ResolvedOption.deserialize(element, helper)); } hintList = hintListBuilder.build(); isOrdered = proto.getIsOrdered(); } public static ResolvedScan deserialize( AnyResolvedScanProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_SINGLE_ROW_SCAN_NODE: return ResolvedSingleRowScan.deserialize( proto.getResolvedSingleRowScanNode(), helper); case RESOLVED_TABLE_SCAN_NODE: return ResolvedTableScan.deserialize( proto.getResolvedTableScanNode(), helper); case RESOLVED_JOIN_SCAN_NODE: return ResolvedJoinScan.deserialize( proto.getResolvedJoinScanNode(), helper); case RESOLVED_ARRAY_SCAN_NODE: return ResolvedArrayScan.deserialize( proto.getResolvedArrayScanNode(), helper); case RESOLVED_FILTER_SCAN_NODE: return ResolvedFilterScan.deserialize( proto.getResolvedFilterScanNode(), helper); case RESOLVED_SET_OPERATION_SCAN_NODE: return ResolvedSetOperationScan.deserialize( proto.getResolvedSetOperationScanNode(), helper); case RESOLVED_ORDER_BY_SCAN_NODE: return ResolvedOrderByScan.deserialize( proto.getResolvedOrderByScanNode(), helper); case RESOLVED_LIMIT_OFFSET_SCAN_NODE: return ResolvedLimitOffsetScan.deserialize( proto.getResolvedLimitOffsetScanNode(), helper); case RESOLVED_WITH_REF_SCAN_NODE: return ResolvedWithRefScan.deserialize( proto.getResolvedWithRefScanNode(), helper); case RESOLVED_ANALYTIC_SCAN_NODE: return ResolvedAnalyticScan.deserialize( proto.getResolvedAnalyticScanNode(), helper); case RESOLVED_SAMPLE_SCAN_NODE: return ResolvedSampleScan.deserialize( proto.getResolvedSampleScanNode(), helper); case RESOLVED_PROJECT_SCAN_NODE: return ResolvedProjectScan.deserialize( proto.getResolvedProjectScanNode(), helper); case RESOLVED_WITH_SCAN_NODE: return ResolvedWithScan.deserialize( proto.getResolvedWithScanNode(), helper); case RESOLVED_TVFSCAN_NODE: return ResolvedTVFScan.deserialize( proto.getResolvedTvfscanNode(), helper); case RESOLVED_RELATION_ARGUMENT_SCAN_NODE: return ResolvedRelationArgumentScan.deserialize( proto.getResolvedRelationArgumentScanNode(), helper); case RESOLVED_AGGREGATE_SCAN_BASE_NODE: return ResolvedAggregateScanBase.deserialize( proto.getResolvedAggregateScanBaseNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedScanProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedScanProto.Builder builder = ResolvedScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedNodeProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedNodeProto.Builder builder) { builder.clear(); AnyResolvedScanProto.Builder childBuilder = AnyResolvedScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedScanNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedScanProto.Builder}) for its parent proto container type. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public abstract void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedScanProto.Builder builder); /** * Serializes this node into the given {@link ResolvedScanProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedNodeProto parent = (ResolvedNodeProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // columnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList columnLists = this.getColumnList(); for (ResolvedColumn element : columnLists) { proto.addColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // hintList is a collection of AST nodes. Serialize each of them. ImmutableList hintLists = this.getHintList(); for (ResolvedOption element : hintLists) { ResolvedOptionProto.Builder hintListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, hintListBuilder); proto.addHintList(hintListBuilder.build()); } // isOrdered is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsOrdered(this.getIsOrdered()); } public final ImmutableList getColumnList() { return columnList; } public final ImmutableList getHintList() { return hintList; } public final boolean getIsOrdered() { return isOrdered; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(hintList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(columnList)) { fields.add(new DebugStringField("column_list", DebugStrings.toStringImpl(columnList))); } if (!hintList.isEmpty()) { fields.add(new DebugStringField("hint_list", hintList)); } if (!DebugStrings.isDefaultValue(isOrdered)) { fields.add(new DebugStringField("is_ordered", DebugStrings.toStringImpl(isOrdered))); } } } /** * Represents a machine learning model as a TVF argument. * is the machine learning model object known to the resolver * (usually through the catalog). */ public static final class ResolvedModel extends ResolvedArgument { private final Model model; protected ResolvedModel(ResolvedModelProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); model = helper.deserialize(proto.getModel()); } public static final ResolvedModel deserialize( ResolvedModelProto proto, DeserializationHelper helper) { return new ResolvedModel(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MODEL; } @Override public final String nodeKindString() { return "Model"; } /** * Serializes this node into a {@link AnyResolvedArgumentProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedArgumentProto.Builder builder = AnyResolvedArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedArgumentProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedArgumentProto.Builder builder) { builder.clear(); ResolvedModelProto.Builder childBuilder = ResolvedModelProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedModelNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedModelProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedModelProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // model is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getModel() != null) { proto.setModel( ResolvedNodes.serialize(this.getModel(), fileDescriptorSetsBuilder)); } } public final Model getModel() { return model; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("model", DebugStrings.toStringImpl(model))); } } } /** * Scan that produces a single row with no columns. Used for queries without * a FROM clause, where all output comes from the select list. */ public static final class ResolvedSingleRowScan extends ResolvedScan { protected ResolvedSingleRowScan(ResolvedSingleRowScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedSingleRowScan deserialize( ResolvedSingleRowScanProto proto, DeserializationHelper helper) { return new ResolvedSingleRowScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SINGLE_ROW_SCAN; } @Override public final String nodeKindString() { return "SingleRowScan"; } /** * Serializes this node into a {@link AnyResolvedScanProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedScanProto.Builder builder = AnyResolvedScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedScanProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedScanProto.Builder builder) { builder.clear(); ResolvedSingleRowScanProto.Builder childBuilder = ResolvedSingleRowScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSingleRowScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSingleRowScanProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedSingleRowScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * Scan a Table. * The [i] should be matched to a Table column by *

.GetColumn([i]). * *

If AnalyzerOptions::prune_unused_columns is true, the and * will include only columns that were referenced * in the user query. (SELECT * counts as referencing all columns.) * This column_list can then be used for column-level ACL checking on tables. * *

for_system_time_expr when non NULL resolves to TIMESTAMP used in * FOR SYSTEM_TIME AS OF clause. The expression is expected to be constant * and no columns are visible to it. * *

If provided, refers to an explicit alias which was used to * reference a Table in the user query. If the Table was given an implicitly * generated alias, then defaults to "". * *

TODO: Enforce in the constructor arg list. For * historical reasons, some clients match to Table columns by * name. All code building this should always set_column_index_list() to * provide the indexes of all columns in

right after the construction * of a ResolvedTableScan. */ public static final class ResolvedTableScan extends ResolvedScan { private final Table table; private final ResolvedExpr forSystemTimeExpr; private final ImmutableList columnIndexList; private final String alias; protected ResolvedTableScan(ResolvedTableScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); table = helper.deserialize(proto.getTable()); if (proto.hasForSystemTimeExpr()) { forSystemTimeExpr = ResolvedExpr.deserialize(proto.getForSystemTimeExpr(), helper); } else { forSystemTimeExpr = null; } columnIndexList = ImmutableList.copyOf(proto.getColumnIndexListList()); alias = proto.getAlias(); } public static final ResolvedTableScan deserialize( ResolvedTableScanProto proto, DeserializationHelper helper) { return new ResolvedTableScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_TABLE_SCAN; } @Override public final String nodeKindString() { return "TableScan"; } /** * Serializes this node into a {@link AnyResolvedScanProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedScanProto.Builder builder = AnyResolvedScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedScanProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedScanProto.Builder builder) { builder.clear(); ResolvedTableScanProto.Builder childBuilder = ResolvedTableScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedTableScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedTableScanProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedTableScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // table is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getTable() != null) { proto.setTable( ResolvedNodes.serialize(this.getTable(), fileDescriptorSetsBuilder)); } // forSystemTimeExpr is an AST node. Call its serialization chain. if (this.getForSystemTimeExpr() != null) { AnyResolvedExprProto.Builder forSystemTimeExprBuilder = AnyResolvedExprProto.newBuilder(); this.getForSystemTimeExpr().serialize( fileDescriptorSetsBuilder, forSystemTimeExprBuilder); proto.setForSystemTimeExpr( forSystemTimeExprBuilder.build()); } // columnIndexList is a collection of leaf types that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.addAllColumnIndexList(this.getColumnIndexList()); // alias is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setAlias(this.getAlias()); } public final Table getTable() { return table; } public final ResolvedExpr getForSystemTimeExpr() { return forSystemTimeExpr; } public final ImmutableList getColumnIndexList() { return columnIndexList; } public final String getAlias() { return alias; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(forSystemTimeExpr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("table", DebugStrings.toStringImpl(table))); } if (forSystemTimeExpr != null) { fields.add(new DebugStringField("for_system_time_expr", forSystemTimeExpr)); } if (!DebugStrings.isDefaultValue(columnIndexList)) { fields.add(new DebugStringField("column_index_list", DebugStrings.toStringCommaSeparatedForInt(columnIndexList))); } if (!DebugStrings.isDefaultValue(alias)) { fields.add(new DebugStringField("alias", DebugStrings.toStringImpl(alias))); } } } /** * A Scan that joins two input scans. * The will contain columns selected from the union * of the input scan's . * When the join is a LEFT/RIGHT/FULL join, ResolvedColumns that came from * the non-joined side get NULL values. */ public static final class ResolvedJoinScan extends ResolvedScan { private final JoinType joinType; private final ResolvedScan leftScan; private final ResolvedScan rightScan; private final ResolvedExpr joinExpr; protected ResolvedJoinScan(ResolvedJoinScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); joinType = proto.getJoinType(); if (proto.hasLeftScan()) { leftScan = ResolvedScan.deserialize(proto.getLeftScan(), helper); } else { leftScan = null; } if (proto.hasRightScan()) { rightScan = ResolvedScan.deserialize(proto.getRightScan(), helper); } else { rightScan = null; } if (proto.hasJoinExpr()) { joinExpr = ResolvedExpr.deserialize(proto.getJoinExpr(), helper); } else { joinExpr = null; } } public static final ResolvedJoinScan deserialize( ResolvedJoinScanProto proto, DeserializationHelper helper) { return new ResolvedJoinScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_JOIN_SCAN; } @Override public final String nodeKindString() { return "JoinScan"; } /** * Serializes this node into a {@link AnyResolvedScanProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedScanProto.Builder builder = AnyResolvedScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedScanProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedScanProto.Builder builder) { builder.clear(); ResolvedJoinScanProto.Builder childBuilder = ResolvedJoinScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedJoinScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedJoinScanProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedJoinScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // joinType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setJoinType(this.getJoinType()); // leftScan is an AST node. Call its serialization chain. if (this.getLeftScan() != null) { AnyResolvedScanProto.Builder leftScanBuilder = AnyResolvedScanProto.newBuilder(); this.getLeftScan().serialize( fileDescriptorSetsBuilder, leftScanBuilder); proto.setLeftScan( leftScanBuilder.build()); } // rightScan is an AST node. Call its serialization chain. if (this.getRightScan() != null) { AnyResolvedScanProto.Builder rightScanBuilder = AnyResolvedScanProto.newBuilder(); this.getRightScan().serialize( fileDescriptorSetsBuilder, rightScanBuilder); proto.setRightScan( rightScanBuilder.build()); } // joinExpr is an AST node. Call its serialization chain. if (this.getJoinExpr() != null) { AnyResolvedExprProto.Builder joinExprBuilder = AnyResolvedExprProto.newBuilder(); this.getJoinExpr().serialize( fileDescriptorSetsBuilder, joinExprBuilder); proto.setJoinExpr( joinExprBuilder.build()); } } public final JoinType getJoinType() { return joinType; } public final ResolvedScan getLeftScan() { return leftScan; } public final ResolvedScan getRightScan() { return rightScan; } public final ResolvedExpr getJoinExpr() { return joinExpr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(leftScan); visitor.descend(rightScan); visitor.descend(joinExpr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(joinType)) { fields.add(new DebugStringField("join_type", DebugStrings.toStringImpl(joinType))); } if (leftScan != null) { fields.add(new DebugStringField("left_scan", leftScan)); } if (rightScan != null) { fields.add(new DebugStringField("right_scan", rightScan)); } if (joinExpr != null) { fields.add(new DebugStringField("join_expr", joinExpr)); } } } /** * Scan an array value, produced from some expression. * *

If input_scan is NULL, this scans the given array value and produces * one row per array element. This can occur when using UNNEST(expression). * *

If is non-NULL, for each row in the stream produced by * input_scan, this evaluates the expression (which must return * an array type) and then produces a stream with one row per array element. * *

If is non-NULL, then this condition is evaluated as an ON * clause for the array join. The named column produced in * may be used inside . * *

If the array is empty (after evaluating ), then * 1. If is false, the scan produces zero rows. * 2. If is true, the scan produces one row with a NULL value for * the . * *

is the new column produced by this scan that stores the * array element value for each row. * *

If present, defines the column produced by this * scan that stores the array offset (0-based) for the corresponding * . * *

This node's column_list can have columns from input_scan, * and . */ public static final class ResolvedArrayScan extends ResolvedScan { private final ResolvedScan inputScan; private final ResolvedExpr arrayExpr; private final ResolvedColumn elementColumn; private final ResolvedColumnHolder arrayOffsetColumn; private final ResolvedExpr joinExpr; private final boolean isOuter; protected ResolvedArrayScan(ResolvedArrayScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } if (proto.hasArrayExpr()) { arrayExpr = ResolvedExpr.deserialize(proto.getArrayExpr(), helper); } else { arrayExpr = null; } elementColumn = helper.deserialize(proto.getElementColumn()); if (proto.hasArrayOffsetColumn()) { arrayOffsetColumn = ResolvedColumnHolder.deserialize(proto.getArrayOffsetColumn(), helper); } else { arrayOffsetColumn = null; } if (proto.hasJoinExpr()) { joinExpr = ResolvedExpr.deserialize(proto.getJoinExpr(), helper); } else { joinExpr = null; } isOuter = proto.getIsOuter(); } public static final ResolvedArrayScan deserialize( ResolvedArrayScanProto proto, DeserializationHelper helper) { return new ResolvedArrayScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ARRAY_SCAN; } @Override public final String nodeKindString() { return "ArrayScan"; } /** * Serializes this node into a {@link AnyResolvedScanProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedScanProto.Builder builder = AnyResolvedScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedScanProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedScanProto.Builder builder) { builder.clear(); ResolvedArrayScanProto.Builder childBuilder = ResolvedArrayScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedArrayScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedArrayScanProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedArrayScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputScan is an AST node. Call its serialization chain. if (this.getInputScan() != null) { AnyResolvedScanProto.Builder inputScanBuilder = AnyResolvedScanProto.newBuilder(); this.getInputScan().serialize( fileDescriptorSetsBuilder, inputScanBuilder); proto.setInputScan( inputScanBuilder.build()); } // arrayExpr is an AST node. Call its serialization chain. if (this.getArrayExpr() != null) { AnyResolvedExprProto.Builder arrayExprBuilder = AnyResolvedExprProto.newBuilder(); this.getArrayExpr().serialize( fileDescriptorSetsBuilder, arrayExprBuilder); proto.setArrayExpr( arrayExprBuilder.build()); } // elementColumn is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getElementColumn() != null) { proto.setElementColumn( ResolvedNodes.serialize(this.getElementColumn(), fileDescriptorSetsBuilder)); } // arrayOffsetColumn is an AST node. Call its serialization chain. if (this.getArrayOffsetColumn() != null) { ResolvedColumnHolderProto.Builder arrayOffsetColumnBuilder = ResolvedColumnHolderProto.newBuilder(); this.getArrayOffsetColumn().serialize( fileDescriptorSetsBuilder, arrayOffsetColumnBuilder); proto.setArrayOffsetColumn( arrayOffsetColumnBuilder.build()); } // joinExpr is an AST node. Call its serialization chain. if (this.getJoinExpr() != null) { AnyResolvedExprProto.Builder joinExprBuilder = AnyResolvedExprProto.newBuilder(); this.getJoinExpr().serialize( fileDescriptorSetsBuilder, joinExprBuilder); proto.setJoinExpr( joinExprBuilder.build()); } // isOuter is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsOuter(this.getIsOuter()); } public final ResolvedScan getInputScan() { return inputScan; } public final ResolvedExpr getArrayExpr() { return arrayExpr; } public final ResolvedColumn getElementColumn() { return elementColumn; } public final ResolvedColumnHolder getArrayOffsetColumn() { return arrayOffsetColumn; } public final ResolvedExpr getJoinExpr() { return joinExpr; } public final boolean getIsOuter() { return isOuter; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(arrayExpr); visitor.descend(arrayOffsetColumn); visitor.descend(joinExpr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (arrayExpr != null) { fields.add(new DebugStringField("array_expr", arrayExpr)); } { fields.add(new DebugStringField("element_column", DebugStrings.toStringImpl(elementColumn))); } if (arrayOffsetColumn != null) { fields.add(new DebugStringField("array_offset_column", arrayOffsetColumn)); } if (joinExpr != null) { fields.add(new DebugStringField("join_expr", joinExpr)); } if (!DebugStrings.isDefaultValue(isOuter)) { fields.add(new DebugStringField("is_outer", DebugStrings.toStringImpl(isOuter))); } } } /** * This wrapper is used for an optional ResolvedColumn inside another node. */ public static final class ResolvedColumnHolder extends ResolvedArgument { private final ResolvedColumn column; protected ResolvedColumnHolder(ResolvedColumnHolderProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); column = helper.deserialize(proto.getColumn()); } public static final ResolvedColumnHolder deserialize( ResolvedColumnHolderProto proto, DeserializationHelper helper) { return new ResolvedColumnHolder(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_COLUMN_HOLDER; } @Override public final String nodeKindString() { return "ColumnHolder"; } /** * Serializes this node into a {@link AnyResolvedArgumentProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedArgumentProto.Builder builder = AnyResolvedArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedArgumentProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedArgumentProto.Builder builder) { builder.clear(); ResolvedColumnHolderProto.Builder childBuilder = ResolvedColumnHolderProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedColumnHolderNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedColumnHolderProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedColumnHolderProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // column is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getColumn() != null) { proto.setColumn( ResolvedNodes.serialize(this.getColumn(), fileDescriptorSetsBuilder)); } } public final ResolvedColumn getColumn() { return column; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("column", DebugStrings.toStringImpl(column))); } } } /** * Scan rows from input_scan, and emit all rows where filter_expr * evaluates to true. filter_expr is always of type bool. * This node's column_list will be a subset of input_scan's column_list. */ public static final class ResolvedFilterScan extends ResolvedScan { private final ResolvedScan inputScan; private final ResolvedExpr filterExpr; protected ResolvedFilterScan(ResolvedFilterScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } if (proto.hasFilterExpr()) { filterExpr = ResolvedExpr.deserialize(proto.getFilterExpr(), helper); } else { filterExpr = null; } } public static final ResolvedFilterScan deserialize( ResolvedFilterScanProto proto, DeserializationHelper helper) { return new ResolvedFilterScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FILTER_SCAN; } @Override public final String nodeKindString() { return "FilterScan"; } /** * Serializes this node into a {@link AnyResolvedScanProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedScanProto.Builder builder = AnyResolvedScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedScanProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedScanProto.Builder builder) { builder.clear(); ResolvedFilterScanProto.Builder childBuilder = ResolvedFilterScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFilterScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedFilterScanProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedFilterScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputScan is an AST node. Call its serialization chain. if (this.getInputScan() != null) { AnyResolvedScanProto.Builder inputScanBuilder = AnyResolvedScanProto.newBuilder(); this.getInputScan().serialize( fileDescriptorSetsBuilder, inputScanBuilder); proto.setInputScan( inputScanBuilder.build()); } // filterExpr is an AST node. Call its serialization chain. if (this.getFilterExpr() != null) { AnyResolvedExprProto.Builder filterExprBuilder = AnyResolvedExprProto.newBuilder(); this.getFilterExpr().serialize( fileDescriptorSetsBuilder, filterExprBuilder); proto.setFilterExpr( filterExprBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ResolvedExpr getFilterExpr() { return filterExpr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(filterExpr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (filterExpr != null) { fields.add(new DebugStringField("filter_expr", filterExpr)); } } } /** * List of group by columns that form a grouping set. * *

Columns must come from group_by_list in ResolvedAggregateScan. * group_by_column_list will not contain any duplicates. There may be more * than one ResolvedGroupingSet in the ResolvedAggregateScan with the same * columns, however. */ public static final class ResolvedGroupingSet extends ResolvedArgument { private final ImmutableList groupByColumnList; protected ResolvedGroupingSet(ResolvedGroupingSetProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder groupByColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getGroupByColumnListList()) { groupByColumnListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } groupByColumnList = groupByColumnListBuilder.build(); } public static final ResolvedGroupingSet deserialize( ResolvedGroupingSetProto proto, DeserializationHelper helper) { return new ResolvedGroupingSet(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GROUPING_SET; } @Override public final String nodeKindString() { return "GroupingSet"; } /** * Serializes this node into a {@link AnyResolvedArgumentProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedArgumentProto.Builder builder = AnyResolvedArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedArgumentProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedArgumentProto.Builder builder) { builder.clear(); ResolvedGroupingSetProto.Builder childBuilder = ResolvedGroupingSetProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGroupingSetNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGroupingSetProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedGroupingSetProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // groupByColumnList is a collection of AST nodes. Serialize each of them. ImmutableList groupByColumnLists = this.getGroupByColumnList(); for (ResolvedColumnRef element : groupByColumnLists) { ResolvedColumnRefProto.Builder groupByColumnListBuilder = ResolvedColumnRefProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, groupByColumnListBuilder); proto.addGroupByColumnList(groupByColumnListBuilder.build()); } } public final ImmutableList getGroupByColumnList() { return groupByColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(groupByColumnList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!groupByColumnList.isEmpty()) { fields.add(new DebugStringField("group_by_column_list", groupByColumnList)); } } } /** * Base class for aggregation scans. Apply aggregation to rows produced from * input_scan, and output aggregated rows. * *

Group by keys in . If is empty, * aggregate all input rows into one output row. * *

Compute all aggregations in . All expressions in * have a ResolvedAggregateFunctionCall with mode * Function::AGGREGATE as their outermost node. * *

The output contains only columns produced from * and . No other columns are visible after * aggregation. */ public static abstract class ResolvedAggregateScanBase extends ResolvedScan { private final ResolvedScan inputScan; private final ImmutableList groupByList; private final ImmutableList aggregateList; protected ResolvedAggregateScanBase(ResolvedAggregateScanBaseProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } ImmutableList.Builder groupByListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getGroupByListList()) { groupByListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } groupByList = groupByListBuilder.build(); ImmutableList.Builder aggregateListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getAggregateListList()) { aggregateListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } aggregateList = aggregateListBuilder.build(); } public static ResolvedAggregateScanBase deserialize( AnyResolvedAggregateScanBaseProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_AGGREGATE_SCAN_NODE: return ResolvedAggregateScan.deserialize( proto.getResolvedAggregateScanNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedAggregateScanBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedAggregateScanBaseProto.Builder builder = ResolvedAggregateScanBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedScanProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedScanProto.Builder builder) { builder.clear(); AnyResolvedAggregateScanBaseProto.Builder childBuilder = AnyResolvedAggregateScanBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAggregateScanBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedAggregateScanBaseProto.Builder}) for its parent proto container type. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public abstract void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedAggregateScanBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedAggregateScanBaseProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedAggregateScanBaseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputScan is an AST node. Call its serialization chain. if (this.getInputScan() != null) { AnyResolvedScanProto.Builder inputScanBuilder = AnyResolvedScanProto.newBuilder(); this.getInputScan().serialize( fileDescriptorSetsBuilder, inputScanBuilder); proto.setInputScan( inputScanBuilder.build()); } // groupByList is a collection of AST nodes. Serialize each of them. ImmutableList groupByLists = this.getGroupByList(); for (ResolvedComputedColumn element : groupByLists) { ResolvedComputedColumnProto.Builder groupByListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, groupByListBuilder); proto.addGroupByList(groupByListBuilder.build()); } // aggregateList is a collection of AST nodes. Serialize each of them. ImmutableList aggregateLists = this.getAggregateList(); for (ResolvedComputedColumn element : aggregateLists) { ResolvedComputedColumnProto.Builder aggregateListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, aggregateListBuilder); proto.addAggregateList(aggregateListBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ImmutableList getGroupByList() { return groupByList; } public final ImmutableList getAggregateList() { return aggregateList; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(groupByList); visitor.descend(aggregateList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (!groupByList.isEmpty()) { fields.add(new DebugStringField("group_by_list", groupByList)); } if (!aggregateList.isEmpty()) { fields.add(new DebugStringField("aggregate_list", aggregateList)); } } } /** * Apply aggregation to rows produced from input_scan, and output aggregated * rows. * *

For each item in , output additional rows computing the * same over the input rows using a particular grouping set. * The aggregation input values, including , computed columns in * , and aggregate function arguments in , * should be computed just once and then reused as aggregation input for each * grouping set. (This ensures that ROLLUP rows have correct totals, even * with non-stable functions in the input.) For each grouping set, the * elements not included in the are * replaced with NULL. * *

is the original list of columns from * GROUP BY ROLLUP(...), if there was a ROLLUP clause, and is used only for * rebuilding equivalent SQL for the resolved AST. Engines should refer to * rather than . */ public static final class ResolvedAggregateScan extends ResolvedAggregateScanBase { private final ImmutableList groupingSetList; private final ImmutableList rollupColumnList; protected ResolvedAggregateScan(ResolvedAggregateScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder groupingSetListBuilder = ImmutableList.builder(); for (ResolvedGroupingSetProto element : proto.getGroupingSetListList()) { groupingSetListBuilder .add(ResolvedGroupingSet.deserialize(element, helper)); } groupingSetList = groupingSetListBuilder.build(); ImmutableList.Builder rollupColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getRollupColumnListList()) { rollupColumnListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } rollupColumnList = rollupColumnListBuilder.build(); } public static final ResolvedAggregateScan deserialize( ResolvedAggregateScanProto proto, DeserializationHelper helper) { return new ResolvedAggregateScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_AGGREGATE_SCAN; } @Override public final String nodeKindString() { return "AggregateScan"; } /** * Serializes this node into a {@link AnyResolvedAggregateScanBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAggregateScanBaseProto.Builder builder = AnyResolvedAggregateScanBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAggregateScanBaseProto.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, AnyResolvedAggregateScanBaseProto.Builder builder) { builder.clear(); ResolvedAggregateScanProto.Builder childBuilder = ResolvedAggregateScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAggregateScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAggregateScanProto.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, ResolvedAggregateScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAggregateScanBaseProto parent = (ResolvedAggregateScanBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // groupingSetList is a collection of AST nodes. Serialize each of them. ImmutableList groupingSetLists = this.getGroupingSetList(); for (ResolvedGroupingSet element : groupingSetLists) { ResolvedGroupingSetProto.Builder groupingSetListBuilder = ResolvedGroupingSetProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, groupingSetListBuilder); proto.addGroupingSetList(groupingSetListBuilder.build()); } // rollupColumnList is a collection of AST nodes. Serialize each of them. ImmutableList rollupColumnLists = this.getRollupColumnList(); for (ResolvedColumnRef element : rollupColumnLists) { ResolvedColumnRefProto.Builder rollupColumnListBuilder = ResolvedColumnRefProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, rollupColumnListBuilder); proto.addRollupColumnList(rollupColumnListBuilder.build()); } } public final ImmutableList getGroupingSetList() { return groupingSetList; } public final ImmutableList getRollupColumnList() { return rollupColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(groupingSetList); visitor.descend(rollupColumnList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!groupingSetList.isEmpty()) { fields.add(new DebugStringField("grouping_set_list", groupingSetList)); } if (!rollupColumnList.isEmpty()) { fields.add(new DebugStringField("rollup_column_list", rollupColumnList)); } } } /** * This is one input item in a ResolvedSetOperation. * The matches 1:1 with the ResolvedSetOperation's * and specifies how columns from map to output columns. * Each column from can map to zero or more output columns. */ public static final class ResolvedSetOperationItem extends ResolvedArgument { private final ResolvedScan scan; private final ImmutableList outputColumnList; protected ResolvedSetOperationItem(ResolvedSetOperationItemProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasScan()) { scan = ResolvedScan.deserialize(proto.getScan(), helper); } else { scan = null; } ImmutableList.Builder outputColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getOutputColumnListList()) { outputColumnListBuilder.add(helper.deserialize(element)); } outputColumnList = outputColumnListBuilder.build(); } public static final ResolvedSetOperationItem deserialize( ResolvedSetOperationItemProto proto, DeserializationHelper helper) { return new ResolvedSetOperationItem(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SET_OPERATION_ITEM; } @Override public final String nodeKindString() { return "SetOperationItem"; } /** * 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(); ResolvedSetOperationItemProto.Builder childBuilder = ResolvedSetOperationItemProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSetOperationItemNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSetOperationItemProto.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, ResolvedSetOperationItemProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // scan is an AST node. Call its serialization chain. if (this.getScan() != null) { AnyResolvedScanProto.Builder scanBuilder = AnyResolvedScanProto.newBuilder(); this.getScan().serialize( fileDescriptorSetsBuilder, scanBuilder); proto.setScan( scanBuilder.build()); } // outputColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList outputColumnLists = this.getOutputColumnList(); for (ResolvedColumn element : outputColumnLists) { proto.addOutputColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } } public final ResolvedScan getScan() { return scan; } public final ImmutableList getOutputColumnList() { return outputColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(scan); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (scan != null) { fields.add(new DebugStringField("scan", scan)); } { fields.add(new DebugStringField("output_column_list", DebugStrings.toStringImpl(outputColumnList))); } } } /** * Apply a set operation (specified by ) on two or more input scans. * *

will have at least two elements. * *

is a set of new ResolvedColumns created by this scan. * Each input ResolvedSetOperationItem has an which * matches 1:1 with and specifies how the input 's * columns map into the final . * *

- Results of {UNION, INTERSECT, EXCEPT} ALL can include duplicate rows. * More precisely, with two input scans, if a given row R appears exactly * m times in first input and n times in second input (m >= 0, n >= 0): * For UNION ALL, R will appear exactly m + n times in the result. * For INTERSECT ALL, R will appear exactly min(m, n) in the result. * For EXCEPT ALL, R will appear exactly max(m - n, 0) in the result. * *

- Results of {UNION, INTERSECT, EXCEPT} DISTINCT cannot contain any * duplicate rows. For UNION and INTERSECT, the DISTINCT is computed * after the result above is computed. For EXCEPT DISTINCT, row R will * appear once in the output if m > 0 and n = 0. * *

- For n (>2) input scans, the above operations generalize so the output is * the same as if the inputs were combined incrementally from left to right. */ public static final class ResolvedSetOperationScan extends ResolvedScan { private final SetOperationType opType; private final ImmutableList inputItemList; protected ResolvedSetOperationScan(ResolvedSetOperationScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); opType = proto.getOpType(); ImmutableList.Builder inputItemListBuilder = ImmutableList.builder(); for (ResolvedSetOperationItemProto element : proto.getInputItemListList()) { inputItemListBuilder .add(ResolvedSetOperationItem.deserialize(element, helper)); } inputItemList = inputItemListBuilder.build(); } public static final ResolvedSetOperationScan deserialize( ResolvedSetOperationScanProto proto, DeserializationHelper helper) { return new ResolvedSetOperationScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SET_OPERATION_SCAN; } @Override public final String nodeKindString() { return "SetOperationScan"; } /** * 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(); ResolvedSetOperationScanProto.Builder childBuilder = ResolvedSetOperationScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSetOperationScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSetOperationScanProto.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, ResolvedSetOperationScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // opType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setOpType(this.getOpType()); // inputItemList is a collection of AST nodes. Serialize each of them. ImmutableList inputItemLists = this.getInputItemList(); for (ResolvedSetOperationItem element : inputItemLists) { ResolvedSetOperationItemProto.Builder inputItemListBuilder = ResolvedSetOperationItemProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, inputItemListBuilder); proto.addInputItemList(inputItemListBuilder.build()); } } public final SetOperationType getOpType() { return opType; } public final ImmutableList getInputItemList() { return inputItemList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputItemList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("op_type", DebugStrings.toStringImpl(opType))); } if (!inputItemList.isEmpty()) { fields.add(new DebugStringField("input_item_list", inputItemList)); } } } /** * Apply ordering to rows produced from input_scan, and output ordered * rows. * *

The must not be empty. Each element identifies * a sort column and indicates direction (ascending or descending). * *

Order Preservation: * A ResolvedScan produces an ordered output if it has =true. * If =false, the scan may discard order. This can happen * even for a ResolvedOrderByScan, if it is the top-level scan in a * subquery (which discards order). * *

The following Scan nodes may have =true, producing or * propagating an ordering: * * ResolvedOrderByScan * * ResolvedLimitOffsetScan * * ResolvedProjectScan * * ResolvedWithScan * Other Scan nodes will always discard ordering. */ public static final class ResolvedOrderByScan extends ResolvedScan { private final ResolvedScan inputScan; private final ImmutableList orderByItemList; protected ResolvedOrderByScan(ResolvedOrderByScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } ImmutableList.Builder orderByItemListBuilder = ImmutableList.builder(); for (ResolvedOrderByItemProto element : proto.getOrderByItemListList()) { orderByItemListBuilder .add(ResolvedOrderByItem.deserialize(element, helper)); } orderByItemList = orderByItemListBuilder.build(); } public static final ResolvedOrderByScan deserialize( ResolvedOrderByScanProto proto, DeserializationHelper helper) { return new ResolvedOrderByScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ORDER_BY_SCAN; } @Override public final String nodeKindString() { return "OrderByScan"; } /** * 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(); ResolvedOrderByScanProto.Builder childBuilder = ResolvedOrderByScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedOrderByScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedOrderByScanProto.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, ResolvedOrderByScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputScan is an AST node. Call its serialization chain. if (this.getInputScan() != null) { AnyResolvedScanProto.Builder inputScanBuilder = AnyResolvedScanProto.newBuilder(); this.getInputScan().serialize( fileDescriptorSetsBuilder, inputScanBuilder); proto.setInputScan( inputScanBuilder.build()); } // 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()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ImmutableList getOrderByItemList() { return orderByItemList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(orderByItemList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (!orderByItemList.isEmpty()) { fields.add(new DebugStringField("order_by_item_list", orderByItemList)); } } } /** * Apply a LIMIT and optional OFFSET to the rows from input_scan. Emit all * rows after OFFSET rows have been scanned and up to LIMIT total rows * emitted. The offset is the number of rows to skip. * E.g., OFFSET 1 means to skip one row, so the first row emitted will be the * second ROW, provided the LIMIT is greater than zero. * *

The arguments to LIMIT OFFSET must be non-negative * integer literals or (possibly casted) query parameters. Query * parameter values must be checked at run-time by ZetaSQL compliant * backend systems. * *

OFFSET is optional and the absence of OFFSET implies OFFSET 0. */ public static final class ResolvedLimitOffsetScan extends ResolvedScan { private final ResolvedScan inputScan; private final ResolvedExpr limit; private final ResolvedExpr offset; protected ResolvedLimitOffsetScan(ResolvedLimitOffsetScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } if (proto.hasLimit()) { limit = ResolvedExpr.deserialize(proto.getLimit(), helper); } else { limit = null; } if (proto.hasOffset()) { offset = ResolvedExpr.deserialize(proto.getOffset(), helper); } else { offset = null; } } public static final ResolvedLimitOffsetScan deserialize( ResolvedLimitOffsetScanProto proto, DeserializationHelper helper) { return new ResolvedLimitOffsetScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_LIMIT_OFFSET_SCAN; } @Override public final String nodeKindString() { return "LimitOffsetScan"; } /** * 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(); ResolvedLimitOffsetScanProto.Builder childBuilder = ResolvedLimitOffsetScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedLimitOffsetScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedLimitOffsetScanProto.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, ResolvedLimitOffsetScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputScan is an AST node. Call its serialization chain. if (this.getInputScan() != null) { AnyResolvedScanProto.Builder inputScanBuilder = AnyResolvedScanProto.newBuilder(); this.getInputScan().serialize( fileDescriptorSetsBuilder, inputScanBuilder); proto.setInputScan( inputScanBuilder.build()); } // 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()); } // offset is an AST node. Call its serialization chain. if (this.getOffset() != null) { AnyResolvedExprProto.Builder offsetBuilder = AnyResolvedExprProto.newBuilder(); this.getOffset().serialize( fileDescriptorSetsBuilder, offsetBuilder); proto.setOffset( offsetBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ResolvedExpr getLimit() { return limit; } public final ResolvedExpr getOffset() { return offset; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(limit); visitor.descend(offset); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (limit != null) { fields.add(new DebugStringField("limit", limit)); } if (offset != null) { fields.add(new DebugStringField("offset", offset)); } } } /** * Scan the subquery defined in a WITH statement. * See ResolvedWithScan for more detail. * The column_list produced here will match 1:1 with the column_list produced * by the referenced subquery and will given a new unique name to each * column produced for this scan. */ public static final class ResolvedWithRefScan extends ResolvedScan { private final String withQueryName; protected ResolvedWithRefScan(ResolvedWithRefScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); withQueryName = proto.getWithQueryName(); } public static final ResolvedWithRefScan deserialize( ResolvedWithRefScanProto proto, DeserializationHelper helper) { return new ResolvedWithRefScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_WITH_REF_SCAN; } @Override public final String nodeKindString() { return "WithRefScan"; } /** * 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(); ResolvedWithRefScanProto.Builder childBuilder = ResolvedWithRefScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedWithRefScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedWithRefScanProto.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, ResolvedWithRefScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // withQueryName is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setWithQueryName(this.getWithQueryName()); } public final String getWithQueryName() { return withQueryName; } @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("with_query_name", DebugStrings.toStringImpl(withQueryName))); } } } /** * Apply analytic functions to rows produced from input_scan. * *

The set of analytic functions are partitioned into a list of analytic * function groups by the window PARTITION BY and the * window ORDER BY. * *

The output contains all columns from , * one column per analytic function. It may also conain partitioning/ordering * expression columns if they reference to select columns. */ public static final class ResolvedAnalyticScan extends ResolvedScan { private final ResolvedScan inputScan; private final ImmutableList functionGroupList; protected ResolvedAnalyticScan(ResolvedAnalyticScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } ImmutableList.Builder functionGroupListBuilder = ImmutableList.builder(); for (ResolvedAnalyticFunctionGroupProto element : proto.getFunctionGroupListList()) { functionGroupListBuilder .add(ResolvedAnalyticFunctionGroup.deserialize(element, helper)); } functionGroupList = functionGroupListBuilder.build(); } public static final ResolvedAnalyticScan deserialize( ResolvedAnalyticScanProto proto, DeserializationHelper helper) { return new ResolvedAnalyticScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ANALYTIC_SCAN; } @Override public final String nodeKindString() { return "AnalyticScan"; } /** * 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(); ResolvedAnalyticScanProto.Builder childBuilder = ResolvedAnalyticScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAnalyticScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAnalyticScanProto.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, ResolvedAnalyticScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputScan is an AST node. Call its serialization chain. if (this.getInputScan() != null) { AnyResolvedScanProto.Builder inputScanBuilder = AnyResolvedScanProto.newBuilder(); this.getInputScan().serialize( fileDescriptorSetsBuilder, inputScanBuilder); proto.setInputScan( inputScanBuilder.build()); } // functionGroupList is a collection of AST nodes. Serialize each of them. ImmutableList functionGroupLists = this.getFunctionGroupList(); for (ResolvedAnalyticFunctionGroup element : functionGroupLists) { ResolvedAnalyticFunctionGroupProto.Builder functionGroupListBuilder = ResolvedAnalyticFunctionGroupProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, functionGroupListBuilder); proto.addFunctionGroupList(functionGroupListBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ImmutableList getFunctionGroupList() { return functionGroupList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(functionGroupList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (!functionGroupList.isEmpty()) { fields.add(new DebugStringField("function_group_list", functionGroupList)); } } } /** * Samples rows from . * Specs: (broken link) * Specs for WITH WEIGHT and PARTITION BY: (broken link) * *

is the identifier for the sampling algorithm and will always be * in lowercase. * For example BERNOULLI, RESERVOIR, SYSTEM. Engines can also support their * own implementation-specific set of sampling algorithms. * *

and specifies the sample size. * If is "ROWS", must be an and non-negative. * If is "PERCENT", must either be a or an and * in the range [0, 100]. * can only be a literal value or a (possibly casted) parameter. * *

is present if we had a REPEATABLE() in the * TABLESAMPLE clause and can only be a literal value or a (possibly * casted) parameter. * *

If present, defines the column produced by this scan that * stores the scaling weight for the corresponding sampled row. * *

can be empty. If is not empty, * must be ROWS and must be RESERVOIR. */ public static final class ResolvedSampleScan extends ResolvedScan { private final ResolvedScan inputScan; private final String method; private final ResolvedExpr size; private final SampleUnit unit; private final ResolvedExpr repeatableArgument; private final ResolvedColumnHolder weightColumn; private final ImmutableList partitionByList; protected ResolvedSampleScan(ResolvedSampleScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } method = proto.getMethod(); if (proto.hasSize()) { size = ResolvedExpr.deserialize(proto.getSize(), helper); } else { size = null; } unit = proto.getUnit(); if (proto.hasRepeatableArgument()) { repeatableArgument = ResolvedExpr.deserialize(proto.getRepeatableArgument(), helper); } else { repeatableArgument = null; } if (proto.hasWeightColumn()) { weightColumn = ResolvedColumnHolder.deserialize(proto.getWeightColumn(), helper); } else { weightColumn = null; } ImmutableList.Builder partitionByListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getPartitionByListList()) { partitionByListBuilder .add(ResolvedExpr.deserialize(element, helper)); } partitionByList = partitionByListBuilder.build(); } public static final ResolvedSampleScan deserialize( ResolvedSampleScanProto proto, DeserializationHelper helper) { return new ResolvedSampleScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SAMPLE_SCAN; } @Override public final String nodeKindString() { return "SampleScan"; } /** * 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(); ResolvedSampleScanProto.Builder childBuilder = ResolvedSampleScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSampleScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSampleScanProto.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, ResolvedSampleScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputScan is an AST node. Call its serialization chain. if (this.getInputScan() != null) { AnyResolvedScanProto.Builder inputScanBuilder = AnyResolvedScanProto.newBuilder(); this.getInputScan().serialize( fileDescriptorSetsBuilder, inputScanBuilder); proto.setInputScan( inputScanBuilder.build()); } // method is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setMethod(this.getMethod()); // size is an AST node. Call its serialization chain. if (this.getSize() != null) { AnyResolvedExprProto.Builder sizeBuilder = AnyResolvedExprProto.newBuilder(); this.getSize().serialize( fileDescriptorSetsBuilder, sizeBuilder); proto.setSize( sizeBuilder.build()); } // unit is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setUnit(this.getUnit()); // repeatableArgument is an AST node. Call its serialization chain. if (this.getRepeatableArgument() != null) { AnyResolvedExprProto.Builder repeatableArgumentBuilder = AnyResolvedExprProto.newBuilder(); this.getRepeatableArgument().serialize( fileDescriptorSetsBuilder, repeatableArgumentBuilder); proto.setRepeatableArgument( repeatableArgumentBuilder.build()); } // weightColumn is an AST node. Call its serialization chain. if (this.getWeightColumn() != null) { ResolvedColumnHolderProto.Builder weightColumnBuilder = ResolvedColumnHolderProto.newBuilder(); this.getWeightColumn().serialize( fileDescriptorSetsBuilder, weightColumnBuilder); proto.setWeightColumn( weightColumnBuilder.build()); } // partitionByList is a collection of AST nodes. Serialize each of them. ImmutableList partitionByLists = this.getPartitionByList(); for (ResolvedExpr element : partitionByLists) { AnyResolvedExprProto.Builder partitionByListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, partitionByListBuilder); proto.addPartitionByList(partitionByListBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final String getMethod() { return method; } public final ResolvedExpr getSize() { return size; } public final SampleUnit getUnit() { return unit; } public final ResolvedExpr getRepeatableArgument() { return repeatableArgument; } public final ResolvedColumnHolder getWeightColumn() { return weightColumn; } public final ImmutableList getPartitionByList() { return partitionByList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(size); visitor.descend(repeatableArgument); visitor.descend(weightColumn); visitor.descend(partitionByList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } { fields.add(new DebugStringField("method", DebugStrings.toStringImpl(method))); } if (size != null) { fields.add(new DebugStringField("size", size)); } { fields.add(new DebugStringField("unit", DebugStrings.toStringImpl(unit))); } if (repeatableArgument != null) { fields.add(new DebugStringField("repeatable_argument", repeatableArgument)); } if (weightColumn != null) { fields.add(new DebugStringField("weight_column", weightColumn)); } if (!partitionByList.isEmpty()) { fields.add(new DebugStringField("partition_by_list", partitionByList)); } } } /** * This is used when an expression is computed and given a name (a new * ResolvedColumn) that can be referenced elsewhere. The new ResolvedColumn * can appear in a column_list or in ResolvedColumnRefs in other expressions, * when appropriate. This node is not an expression itself - it is a * container that holds an expression. */ public static final class ResolvedComputedColumn extends ResolvedArgument { private final ResolvedColumn column; private final ResolvedExpr expr; protected ResolvedComputedColumn(ResolvedComputedColumnProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); column = helper.deserialize(proto.getColumn()); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } } public static final ResolvedComputedColumn deserialize( ResolvedComputedColumnProto proto, DeserializationHelper helper) { return new ResolvedComputedColumn(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_COMPUTED_COLUMN; } @Override public final String nodeKindString() { return "ComputedColumn"; } /** * 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(); ResolvedComputedColumnProto.Builder childBuilder = ResolvedComputedColumnProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedComputedColumnNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedComputedColumnProto.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, ResolvedComputedColumnProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // column is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getColumn() != null) { proto.setColumn( ResolvedNodes.serialize(this.getColumn(), fileDescriptorSetsBuilder)); } // 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 ResolvedColumn getColumn() { return column; } 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); } } /** * This represents one column of an ORDER BY clause, with the requested * ordering direction. * *

indicates the COLLATE specific rules of ordering. * If non-NULL, must be a string literal or a string parameter. * See (broken link). * *

indicates the ordering of NULL values relative to non-NULL * values. NULLS_FIRST indicates that NULLS sort prior to non-NULL values, * and NULLS_LAST indicates that NULLS sort after non-NULL values. */ public static final class ResolvedOrderByItem extends ResolvedArgument { private final ResolvedColumnRef columnRef; private final ResolvedExpr collationName; private final boolean isDescending; private final NullOrderMode nullOrder; protected ResolvedOrderByItem(ResolvedOrderByItemProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasColumnRef()) { columnRef = ResolvedColumnRef.deserialize(proto.getColumnRef(), helper); } else { columnRef = null; } if (proto.hasCollationName()) { collationName = ResolvedExpr.deserialize(proto.getCollationName(), helper); } else { collationName = null; } isDescending = proto.getIsDescending(); nullOrder = proto.getNullOrder(); } public static final ResolvedOrderByItem deserialize( ResolvedOrderByItemProto proto, DeserializationHelper helper) { return new ResolvedOrderByItem(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ORDER_BY_ITEM; } @Override public final String nodeKindString() { return "OrderByItem"; } /** * 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(); ResolvedOrderByItemProto.Builder childBuilder = ResolvedOrderByItemProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedOrderByItemNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedOrderByItemProto.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, ResolvedOrderByItemProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // columnRef is an AST node. Call its serialization chain. if (this.getColumnRef() != null) { ResolvedColumnRefProto.Builder columnRefBuilder = ResolvedColumnRefProto.newBuilder(); this.getColumnRef().serialize( fileDescriptorSetsBuilder, columnRefBuilder); proto.setColumnRef( columnRefBuilder.build()); } // collationName is an AST node. Call its serialization chain. if (this.getCollationName() != null) { AnyResolvedExprProto.Builder collationNameBuilder = AnyResolvedExprProto.newBuilder(); this.getCollationName().serialize( fileDescriptorSetsBuilder, collationNameBuilder); proto.setCollationName( collationNameBuilder.build()); } // isDescending is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsDescending(this.getIsDescending()); // nullOrder is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setNullOrder(this.getNullOrder()); } public final ResolvedColumnRef getColumnRef() { return columnRef; } public final ResolvedExpr getCollationName() { return collationName; } public final boolean getIsDescending() { return isDescending; } public final NullOrderMode getNullOrder() { return nullOrder; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnRef); visitor.descend(collationName); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (columnRef != null) { fields.add(new DebugStringField("column_ref", columnRef)); } if (collationName != null) { fields.add(new DebugStringField("collation_name", collationName)); } if (!DebugStrings.isDefaultValue(isDescending)) { fields.add(new DebugStringField("is_descending", DebugStrings.toStringImpl(isDescending))); } if (!DebugStrings.isDefaultValue(nullOrder)) { fields.add(new DebugStringField("null_order", DebugStrings.toStringImpl(nullOrder))); } } } /** * This is used in CREATE TABLE statements to provide column annotations * such as NOT NULL and OPTIONS(). * *

This class is recursive. It mirrors the structure of the column type * except that child_list might be truncated. * *

For ARRAY: * If the element or its subfield has annotations, then child_list.size() * is 1, and child_list(0) stores the element annotations. * Otherwise child_list is empty. * For STRUCT: * If the i-th field has annotations then child_list(i) stores the * field annotations. * Otherwise either child_list.size() <= i or child_list(i) is trivial. * If none of the fields and none of their subfields has annotations, then * child_list is empty. * For other types, child_list is empty. */ public static final class ResolvedColumnAnnotations extends ResolvedArgument { private final boolean notNull; private final ImmutableList optionList; private final ImmutableList childList; protected ResolvedColumnAnnotations(ResolvedColumnAnnotationsProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); notNull = proto.getNotNull(); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); ImmutableList.Builder childListBuilder = ImmutableList.builder(); for (ResolvedColumnAnnotationsProto element : proto.getChildListList()) { childListBuilder .add(ResolvedColumnAnnotations.deserialize(element, helper)); } childList = childListBuilder.build(); } public static final ResolvedColumnAnnotations deserialize( ResolvedColumnAnnotationsProto proto, DeserializationHelper helper) { return new ResolvedColumnAnnotations(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_COLUMN_ANNOTATIONS; } @Override public final String nodeKindString() { return "ColumnAnnotations"; } /** * 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(); ResolvedColumnAnnotationsProto.Builder childBuilder = ResolvedColumnAnnotationsProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedColumnAnnotationsNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedColumnAnnotationsProto.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, ResolvedColumnAnnotationsProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // notNull is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setNotNull(this.getNotNull()); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // childList is a collection of AST nodes. Serialize each of them. ImmutableList childLists = this.getChildList(); for (ResolvedColumnAnnotations element : childLists) { ResolvedColumnAnnotationsProto.Builder childListBuilder = ResolvedColumnAnnotationsProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, childListBuilder); proto.addChildList(childListBuilder.build()); } } public final boolean getNotNull() { return notNull; } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getChildList() { return childList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(childList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(notNull)) { fields.add(new DebugStringField("not_null", DebugStrings.toStringImpl(notNull))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!childList.isEmpty()) { fields.add(new DebugStringField("child_list", childList)); } } } /** * indicates the expression that defines the column. The type of * the expression will always match the type of the column. * - The can contain ResolvedColumnRefs corresponding to * ResolvedColumnDefinition. for any of the * ResolvedColumnDefinitions in the enclosing statement. * - The expression can never include a subquery. * *

indicates whether the value of the expression should be * pre-emptively computed to save work at read time. When is_stored is true, * cannot contain a volatile function (e.g. RAND). * *

indicates that the value of this column should be calculated * at write time. As opposed to the can contain * volatile functions (e.g. RAND). * *

Only one of or can be true. * *

See (broken link). */ public static final class ResolvedGeneratedColumnInfo extends ResolvedArgument { private final ResolvedExpr expression; private final boolean isStored; private final boolean isOnWrite; protected ResolvedGeneratedColumnInfo(ResolvedGeneratedColumnInfoProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpression()) { expression = ResolvedExpr.deserialize(proto.getExpression(), helper); } else { expression = null; } isStored = proto.getIsStored(); isOnWrite = proto.getIsOnWrite(); } public static final ResolvedGeneratedColumnInfo deserialize( ResolvedGeneratedColumnInfoProto proto, DeserializationHelper helper) { return new ResolvedGeneratedColumnInfo(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GENERATED_COLUMN_INFO; } @Override public final String nodeKindString() { return "GeneratedColumnInfo"; } /** * 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(); ResolvedGeneratedColumnInfoProto.Builder childBuilder = ResolvedGeneratedColumnInfoProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGeneratedColumnInfoNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGeneratedColumnInfoProto.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, ResolvedGeneratedColumnInfoProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // expression is an AST node. Call its serialization chain. if (this.getExpression() != null) { AnyResolvedExprProto.Builder expressionBuilder = AnyResolvedExprProto.newBuilder(); this.getExpression().serialize( fileDescriptorSetsBuilder, expressionBuilder); proto.setExpression( expressionBuilder.build()); } // isStored is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsStored(this.getIsStored()); // isOnWrite is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsOnWrite(this.getIsOnWrite()); } public final ResolvedExpr getExpression() { return expression; } public final boolean getIsStored() { return isStored; } public final boolean getIsOnWrite() { return isOnWrite; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expression != null) { fields.add(new DebugStringField("expression", expression)); } { fields.add(new DebugStringField("is_stored", DebugStrings.toStringImpl(isStored))); } if (!DebugStrings.isDefaultValue(isOnWrite)) { fields.add(new DebugStringField("is_on_write", DebugStrings.toStringImpl(isOnWrite))); } } } /** * This is used in CREATE TABLE statements to provide an explicit column * definition. * *

if is TRUE, then the column won't show up in SELECT * queries. * *

if is non-NULL, then this table column is a * generated column. * *

defines an ID for the column, which may appear in expressions in * the PARTITION BY, CLUSTER BY clause or if either * is present. */ public static final class ResolvedColumnDefinition extends ResolvedArgument { private final String name; private final Type type; private final ResolvedColumnAnnotations annotations; private final boolean isHidden; private final ResolvedColumn column; private final ResolvedGeneratedColumnInfo generatedColumnInfo; protected ResolvedColumnDefinition(ResolvedColumnDefinitionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); type = helper.deserialize(proto.getType()); if (proto.hasAnnotations()) { annotations = ResolvedColumnAnnotations.deserialize(proto.getAnnotations(), helper); } else { annotations = null; } isHidden = proto.getIsHidden(); column = helper.deserialize(proto.getColumn()); if (proto.hasGeneratedColumnInfo()) { generatedColumnInfo = ResolvedGeneratedColumnInfo.deserialize(proto.getGeneratedColumnInfo(), helper); } else { generatedColumnInfo = null; } } public static final ResolvedColumnDefinition deserialize( ResolvedColumnDefinitionProto proto, DeserializationHelper helper) { return new ResolvedColumnDefinition(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_COLUMN_DEFINITION; } @Override public final String nodeKindString() { return "ColumnDefinition"; } /** * 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(); ResolvedColumnDefinitionProto.Builder childBuilder = ResolvedColumnDefinitionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedColumnDefinitionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedColumnDefinitionProto.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, ResolvedColumnDefinitionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) 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()); // 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)); } // annotations is an AST node. Call its serialization chain. if (this.getAnnotations() != null) { ResolvedColumnAnnotationsProto.Builder annotationsBuilder = ResolvedColumnAnnotationsProto.newBuilder(); this.getAnnotations().serialize( fileDescriptorSetsBuilder, annotationsBuilder); proto.setAnnotations( annotationsBuilder.build()); } // isHidden is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsHidden(this.getIsHidden()); // 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)); } // generatedColumnInfo is an AST node. Call its serialization chain. if (this.getGeneratedColumnInfo() != null) { ResolvedGeneratedColumnInfoProto.Builder generatedColumnInfoBuilder = ResolvedGeneratedColumnInfoProto.newBuilder(); this.getGeneratedColumnInfo().serialize( fileDescriptorSetsBuilder, generatedColumnInfoBuilder); proto.setGeneratedColumnInfo( generatedColumnInfoBuilder.build()); } } public final String getName() { return name; } public final Type getType() { return type; } public final ResolvedColumnAnnotations getAnnotations() { return annotations; } public final boolean getIsHidden() { return isHidden; } public final ResolvedColumn getColumn() { return column; } public final ResolvedGeneratedColumnInfo getGeneratedColumnInfo() { return generatedColumnInfo; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(annotations); visitor.descend(generatedColumnInfo); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } { fields.add(new DebugStringField("type", DebugStrings.toStringImpl(type))); } if (annotations != null) { fields.add(new DebugStringField("annotations", annotations)); } if (!DebugStrings.isDefaultValue(isHidden)) { fields.add(new DebugStringField("is_hidden", DebugStrings.toStringImpl(isHidden))); } if (!DebugStrings.isDefaultValue(column)) { fields.add(new DebugStringField("column", DebugStrings.toStringImpl(column))); } if (generatedColumnInfo != null) { fields.add(new DebugStringField("generated_column_info", generatedColumnInfo)); } } } /** * This represents the PRIMARY KEY constraint on a table. * provides the offsets of the column definitions that * comprise the primary key. This is empty when a * 0-element primary key is defined. */ public static final class ResolvedPrimaryKey extends ResolvedArgument { private final ImmutableList columnOffsetList; private final ImmutableList optionList; protected ResolvedPrimaryKey(ResolvedPrimaryKeyProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); columnOffsetList = ImmutableList.copyOf(proto.getColumnOffsetListList()); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } public static final ResolvedPrimaryKey deserialize( ResolvedPrimaryKeyProto proto, DeserializationHelper helper) { return new ResolvedPrimaryKey(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PRIMARY_KEY; } @Override public final String nodeKindString() { return "PrimaryKey"; } /** * 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(); ResolvedPrimaryKeyProto.Builder childBuilder = ResolvedPrimaryKeyProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedPrimaryKeyNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedPrimaryKeyProto.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, ResolvedPrimaryKeyProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // columnOffsetList 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.addAllColumnOffsetList(this.getColumnOffsetList()); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } } public final ImmutableList getColumnOffsetList() { return columnOffsetList; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("column_offset_list", DebugStrings.toStringCommaSeparatedForInt(columnOffsetList))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This represents the FOREIGN KEY constraint on a table. It is of the form: * * CONSTRAINT * FOREIGN KEY * REFERENCES * * * * * * *

uniquely identifies the constraint. * *

provides the offsets of the column * definitions for the table defining the foreign key. * *

identifies the table this constraint references. * *

provides the offsets of the column * definitions for the table referenced by the foreign key. * *

specifies how referencing keys with null values are handled. * *

specifies what action to take, if any, when a referenced * value is updated. * *

specifies what action to take, if any, when a row with a * referenced values is deleted. * *

specifies whether or not the constraint is enforced. * *

for foreign key table constraints. Empty for foreign key * column attributes (see instead ResolvedColumnAnnotations). */ public static final class ResolvedForeignKey extends ResolvedArgument { private final String constraintName; private final ImmutableList referencingColumnOffsetList; private final Table referencedTable; private final ImmutableList referencedColumnOffsetList; private final MatchMode matchMode; private final ActionOperation updateAction; private final ActionOperation deleteAction; private final boolean enforced; private final ImmutableList optionList; protected ResolvedForeignKey(ResolvedForeignKeyProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); constraintName = proto.getConstraintName(); referencingColumnOffsetList = ImmutableList.copyOf(proto.getReferencingColumnOffsetListList()); referencedTable = helper.deserialize(proto.getReferencedTable()); referencedColumnOffsetList = ImmutableList.copyOf(proto.getReferencedColumnOffsetListList()); matchMode = proto.getMatchMode(); updateAction = proto.getUpdateAction(); deleteAction = proto.getDeleteAction(); enforced = proto.getEnforced(); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } public static final ResolvedForeignKey deserialize( ResolvedForeignKeyProto proto, DeserializationHelper helper) { return new ResolvedForeignKey(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FOREIGN_KEY; } @Override public final String nodeKindString() { return "ForeignKey"; } /** * 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(); ResolvedForeignKeyProto.Builder childBuilder = ResolvedForeignKeyProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedForeignKeyNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedForeignKeyProto.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, ResolvedForeignKeyProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // constraintName is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setConstraintName(this.getConstraintName()); // referencingColumnOffsetList 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.addAllReferencingColumnOffsetList(this.getReferencingColumnOffsetList()); // referencedTable is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getReferencedTable() != null) { proto.setReferencedTable( ResolvedNodes.serialize(this.getReferencedTable(), fileDescriptorSetsBuilder)); } // referencedColumnOffsetList 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.addAllReferencedColumnOffsetList(this.getReferencedColumnOffsetList()); // matchMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setMatchMode(this.getMatchMode()); // updateAction is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setUpdateAction(this.getUpdateAction()); // deleteAction is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setDeleteAction(this.getDeleteAction()); // enforced is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEnforced(this.getEnforced()); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } } public final String getConstraintName() { return constraintName; } public final ImmutableList getReferencingColumnOffsetList() { return referencingColumnOffsetList; } public final Table getReferencedTable() { return referencedTable; } public final ImmutableList getReferencedColumnOffsetList() { return referencedColumnOffsetList; } public final MatchMode getMatchMode() { return matchMode; } public final ActionOperation getUpdateAction() { return updateAction; } public final ActionOperation getDeleteAction() { return deleteAction; } public final boolean getEnforced() { return enforced; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("constraint_name", DebugStrings.toStringImpl(constraintName))); } { fields.add(new DebugStringField("referencing_column_offset_list", DebugStrings.toStringCommaSeparatedForInt(referencingColumnOffsetList))); } { fields.add(new DebugStringField("referenced_table", DebugStrings.toStringImpl(referencedTable))); } { fields.add(new DebugStringField("referenced_column_offset_list", DebugStrings.toStringCommaSeparatedForInt(referencedColumnOffsetList))); } { fields.add(new DebugStringField("match_mode", DebugStrings.toStringImpl(matchMode))); } { fields.add(new DebugStringField("update_action", DebugStrings.toStringImpl(updateAction))); } { fields.add(new DebugStringField("delete_action", DebugStrings.toStringImpl(deleteAction))); } { fields.add(new DebugStringField("enforced", DebugStrings.toStringImpl(enforced))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This represents the CHECK constraint on a table. It is of the form: * * CONSTRAINT * CHECK * * * *

uniquely identifies the constraint. * *

defines a boolean expression to be evaluated when the row is * updated. If the result is FALSE, update to the row is not allowed. * *

specifies whether or not the constraint is enforced. * *

list of options for check constraint. * *

See (broken link). */ public static final class ResolvedCheckConstraint extends ResolvedArgument { private final String constraintName; private final ResolvedExpr expression; private final boolean enforced; private final ImmutableList optionList; protected ResolvedCheckConstraint(ResolvedCheckConstraintProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); constraintName = proto.getConstraintName(); if (proto.hasExpression()) { expression = ResolvedExpr.deserialize(proto.getExpression(), helper); } else { expression = null; } enforced = proto.getEnforced(); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } public static final ResolvedCheckConstraint deserialize( ResolvedCheckConstraintProto proto, DeserializationHelper helper) { return new ResolvedCheckConstraint(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CHECK_CONSTRAINT; } @Override public final String nodeKindString() { return "CheckConstraint"; } /** * 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(); ResolvedCheckConstraintProto.Builder childBuilder = ResolvedCheckConstraintProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCheckConstraintNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCheckConstraintProto.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, ResolvedCheckConstraintProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // constraintName is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setConstraintName(this.getConstraintName()); // expression is an AST node. Call its serialization chain. if (this.getExpression() != null) { AnyResolvedExprProto.Builder expressionBuilder = AnyResolvedExprProto.newBuilder(); this.getExpression().serialize( fileDescriptorSetsBuilder, expressionBuilder); proto.setExpression( expressionBuilder.build()); } // enforced is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEnforced(this.getEnforced()); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } } public final String getConstraintName() { return constraintName; } public final ResolvedExpr getExpression() { return expression; } public final boolean getEnforced() { return enforced; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("constraint_name", DebugStrings.toStringImpl(constraintName))); } if (expression != null) { fields.add(new DebugStringField("expression", expression)); } { fields.add(new DebugStringField("enforced", DebugStrings.toStringImpl(enforced))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This is used in ResolvedQueryStmt to provide a user-visible name * for each output column. */ public static final class ResolvedOutputColumn extends ResolvedArgument { private final String name; private final ResolvedColumn column; protected ResolvedOutputColumn(ResolvedOutputColumnProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); column = helper.deserialize(proto.getColumn()); } public static final ResolvedOutputColumn deserialize( ResolvedOutputColumnProto proto, DeserializationHelper helper) { return new ResolvedOutputColumn(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_OUTPUT_COLUMN; } @Override public final String nodeKindString() { return "OutputColumn"; } /** * 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(); ResolvedOutputColumnProto.Builder childBuilder = ResolvedOutputColumnProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedOutputColumnNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedOutputColumnProto.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, ResolvedOutputColumnProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) 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()); // column is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getColumn() != null) { proto.setColumn( ResolvedNodes.serialize(this.getColumn(), fileDescriptorSetsBuilder)); } } public final String getName() { return name; } public final ResolvedColumn getColumn() { return column; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } protected String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * A Project node computes new expression values, and possibly drops * columns from the input Scan's column_list. * *

Each entry in is a new column computed from an expression. * *

The column_list can include any columns from input_scan, plus these * newly computed columns. * *

NOTE: This scan will propagate the is_ordered property of * by default. To make this scan unordered, call set_is_ordered(false). */ public static final class ResolvedProjectScan extends ResolvedScan { private final ImmutableList exprList; private final ResolvedScan inputScan; protected ResolvedProjectScan(ResolvedProjectScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder exprListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getExprListList()) { exprListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } exprList = exprListBuilder.build(); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } } public static final ResolvedProjectScan deserialize( ResolvedProjectScanProto proto, DeserializationHelper helper) { return new ResolvedProjectScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PROJECT_SCAN; } @Override public final String nodeKindString() { return "ProjectScan"; } /** * 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(); ResolvedProjectScanProto.Builder childBuilder = ResolvedProjectScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedProjectScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedProjectScanProto.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, ResolvedProjectScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // exprList is a collection of AST nodes. Serialize each of them. ImmutableList exprLists = this.getExprList(); for (ResolvedComputedColumn element : exprLists) { ResolvedComputedColumnProto.Builder exprListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, exprListBuilder); proto.addExprList(exprListBuilder.build()); } // inputScan is an AST node. Call its serialization chain. if (this.getInputScan() != null) { AnyResolvedScanProto.Builder inputScanBuilder = AnyResolvedScanProto.newBuilder(); this.getInputScan().serialize( fileDescriptorSetsBuilder, inputScanBuilder); proto.setInputScan( inputScanBuilder.build()); } } public final ImmutableList getExprList() { return exprList; } public final ResolvedScan getInputScan() { return inputScan; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(exprList); visitor.descend(inputScan); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!exprList.isEmpty()) { fields.add(new DebugStringField("expr_list", exprList)); } if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } } } /** * This scan represents a call to a table-valued function (TVF). Each TVF * returns an entire output relation instead of a single scalar value. The * enclosing query may refer to the TVF as if it were a table subquery. The * TVF may accept scalar arguments and/or other input relations. * *

Scalar arguments work the same way as arguments for non-table-valued * functions: in the resolved AST, their types are equal to the required * argument types specified in the function signature. * *

The function signature may also include relation arguments, and any such * relation argument may specify a required schema. If such a required schema * is present, then in the resolved AST, the ResolvedScan for each relational * ResolvedTVFArgument is guaranteed to have the same number of columns as * the required schema, and the provided columns match position-wise with the * required columns. Each provided column has the same name and type as the * corresponding required column. * *

is a set of new ResolvedColumns created by this scan. * These output columns match positionally with the columns in the output * schema of . * *

The TableValuedFunction entry that the catalog returned for this TVF * scan. Contains non-concrete function signatures which may include * arguments with templated types. * The concrete table function signature for this TVF call, * including the types of all scalar arguments and the * number and types of columns of all table-valued * arguments. An engine may also subclass this object to * provide extra custom information and return an instance * of the subclass from the TableValuedFunction::Resolve * method. * The vector of resolved arguments for this TVF call. * The AS alias for the scan, or empty if none. */ public static final class ResolvedTVFScan extends ResolvedScan { private final TableValuedFunction tvf; private final TVFSignature signature; private final ImmutableList argumentList; private final String alias; protected ResolvedTVFScan(ResolvedTVFScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); tvf = helper.deserialize(proto.getTvf()); signature = helper.deserialize(proto.getSignature()); ImmutableList.Builder argumentListBuilder = ImmutableList.builder(); for (ResolvedTVFArgumentProto element : proto.getArgumentListList()) { argumentListBuilder .add(ResolvedTVFArgument.deserialize(element, helper)); } argumentList = argumentListBuilder.build(); alias = proto.getAlias(); } public static final ResolvedTVFScan deserialize( ResolvedTVFScanProto proto, DeserializationHelper helper) { return new ResolvedTVFScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_TVFSCAN; } @Override public final String nodeKindString() { return "TVFScan"; } /** * 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(); ResolvedTVFScanProto.Builder childBuilder = ResolvedTVFScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedTvfscanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedTVFScanProto.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, ResolvedTVFScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // tvf is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getTvf() != null) { proto.setTvf( ResolvedNodes.serialize(this.getTvf(), 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 (ResolvedTVFArgument element : argumentLists) { ResolvedTVFArgumentProto.Builder argumentListBuilder = ResolvedTVFArgumentProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, argumentListBuilder); proto.addArgumentList(argumentListBuilder.build()); } // alias is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setAlias(this.getAlias()); } public final TableValuedFunction getTvf() { return tvf; } public final TVFSignature getSignature() { return signature; } public final ImmutableList getArgumentList() { return argumentList; } public final String getAlias() { return alias; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(argumentList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("tvf", DebugStrings.toStringImpl(tvf))); } { fields.add(new DebugStringField("signature", DebugStrings.toStringImpl(signature))); } if (!argumentList.isEmpty()) { fields.add(new DebugStringField("argument_list", argumentList)); } if (!DebugStrings.isDefaultValue(alias)) { fields.add(new DebugStringField("alias", DebugStrings.toStringImpl(alias))); } } } /** * This represents an argument to a table-valued function (TVF). The argument * can be semantically scalar, relational or represent a model. Only one of * the three fields will be set. * *

The expression representing a scalar TVF argument. * The scan representing a relational TVF argument. * The model representing an ML model TVF argument. * *

maps columns from into specific columns * of the TVF argument's input schema, matching those columns positionally. * i.e. 's column_list may have fewer columns or out-of-order columns, * and this vector maps those columns into specific TVF input columns. */ public static final class ResolvedTVFArgument extends ResolvedArgument { private final ResolvedExpr expr; private final ResolvedScan scan; private final ResolvedModel model; private final ImmutableList argumentColumnList; protected ResolvedTVFArgument(ResolvedTVFArgumentProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } if (proto.hasScan()) { scan = ResolvedScan.deserialize(proto.getScan(), helper); } else { scan = null; } if (proto.hasModel()) { model = ResolvedModel.deserialize(proto.getModel(), helper); } else { model = null; } ImmutableList.Builder argumentColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getArgumentColumnListList()) { argumentColumnListBuilder.add(helper.deserialize(element)); } argumentColumnList = argumentColumnListBuilder.build(); } public static final ResolvedTVFArgument deserialize( ResolvedTVFArgumentProto proto, DeserializationHelper helper) { return new ResolvedTVFArgument(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_TVFARGUMENT; } @Override public final String nodeKindString() { return "TVFArgument"; } /** * 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(); ResolvedTVFArgumentProto.Builder childBuilder = ResolvedTVFArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedTvfargumentNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedTVFArgumentProto.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, ResolvedTVFArgumentProto.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()); } // scan is an AST node. Call its serialization chain. if (this.getScan() != null) { AnyResolvedScanProto.Builder scanBuilder = AnyResolvedScanProto.newBuilder(); this.getScan().serialize( fileDescriptorSetsBuilder, scanBuilder); proto.setScan( scanBuilder.build()); } // model is an AST node. Call its serialization chain. if (this.getModel() != null) { ResolvedModelProto.Builder modelBuilder = ResolvedModelProto.newBuilder(); this.getModel().serialize( fileDescriptorSetsBuilder, modelBuilder); proto.setModel( modelBuilder.build()); } // argumentColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList argumentColumnLists = this.getArgumentColumnList(); for (ResolvedColumn element : argumentColumnLists) { proto.addArgumentColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } } public final ResolvedExpr getExpr() { return expr; } public final ResolvedScan getScan() { return scan; } public final ResolvedModel getModel() { return model; } public final ImmutableList getArgumentColumnList() { return argumentColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); visitor.descend(scan); visitor.descend(model); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } if (scan != null) { fields.add(new DebugStringField("scan", scan)); } if (model != null) { fields.add(new DebugStringField("model", model)); } if (!DebugStrings.isDefaultValue(argumentColumnList)) { fields.add(new DebugStringField("argument_column_list", DebugStrings.toStringImpl(argumentColumnList))); } } } /** * The superclass of all ZetaSQL statements. */ public static abstract class ResolvedStatement extends ResolvedNode { private final ImmutableList hintList; protected ResolvedStatement(ResolvedStatementProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder hintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getHintListList()) { hintListBuilder .add(ResolvedOption.deserialize(element, helper)); } hintList = hintListBuilder.build(); } public static ResolvedStatement deserialize( AnyResolvedStatementProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_EXPLAIN_STMT_NODE: return ResolvedExplainStmt.deserialize( proto.getResolvedExplainStmtNode(), helper); case RESOLVED_QUERY_STMT_NODE: return ResolvedQueryStmt.deserialize( proto.getResolvedQueryStmtNode(), helper); case RESOLVED_CREATE_STATEMENT_NODE: return ResolvedCreateStatement.deserialize( proto.getResolvedCreateStatementNode(), helper); case RESOLVED_EXPORT_DATA_STMT_NODE: return ResolvedExportDataStmt.deserialize( proto.getResolvedExportDataStmtNode(), helper); case RESOLVED_DEFINE_TABLE_STMT_NODE: return ResolvedDefineTableStmt.deserialize( proto.getResolvedDefineTableStmtNode(), helper); case RESOLVED_DESCRIBE_STMT_NODE: return ResolvedDescribeStmt.deserialize( proto.getResolvedDescribeStmtNode(), helper); case RESOLVED_SHOW_STMT_NODE: return ResolvedShowStmt.deserialize( proto.getResolvedShowStmtNode(), helper); case RESOLVED_BEGIN_STMT_NODE: return ResolvedBeginStmt.deserialize( proto.getResolvedBeginStmtNode(), helper); case RESOLVED_COMMIT_STMT_NODE: return ResolvedCommitStmt.deserialize( proto.getResolvedCommitStmtNode(), helper); case RESOLVED_ROLLBACK_STMT_NODE: return ResolvedRollbackStmt.deserialize( proto.getResolvedRollbackStmtNode(), helper); case RESOLVED_DROP_STMT_NODE: return ResolvedDropStmt.deserialize( proto.getResolvedDropStmtNode(), helper); case RESOLVED_INSERT_STMT_NODE: return ResolvedInsertStmt.deserialize( proto.getResolvedInsertStmtNode(), helper); case RESOLVED_DELETE_STMT_NODE: return ResolvedDeleteStmt.deserialize( proto.getResolvedDeleteStmtNode(), helper); case RESOLVED_UPDATE_STMT_NODE: return ResolvedUpdateStmt.deserialize( proto.getResolvedUpdateStmtNode(), helper); case RESOLVED_GRANT_OR_REVOKE_STMT_NODE: return ResolvedGrantOrRevokeStmt.deserialize( proto.getResolvedGrantOrRevokeStmtNode(), helper); case RESOLVED_ALTER_TABLE_SET_OPTIONS_STMT_NODE: return ResolvedAlterTableSetOptionsStmt.deserialize( proto.getResolvedAlterTableSetOptionsStmtNode(), helper); case RESOLVED_RENAME_STMT_NODE: return ResolvedRenameStmt.deserialize( proto.getResolvedRenameStmtNode(), helper); case RESOLVED_CREATE_ROW_ACCESS_POLICY_STMT_NODE: return ResolvedCreateRowAccessPolicyStmt.deserialize( proto.getResolvedCreateRowAccessPolicyStmtNode(), helper); case RESOLVED_DROP_ROW_ACCESS_POLICY_STMT_NODE: return ResolvedDropRowAccessPolicyStmt.deserialize( proto.getResolvedDropRowAccessPolicyStmtNode(), helper); case RESOLVED_DROP_FUNCTION_STMT_NODE: return ResolvedDropFunctionStmt.deserialize( proto.getResolvedDropFunctionStmtNode(), helper); case RESOLVED_CALL_STMT_NODE: return ResolvedCallStmt.deserialize( proto.getResolvedCallStmtNode(), helper); case RESOLVED_IMPORT_STMT_NODE: return ResolvedImportStmt.deserialize( proto.getResolvedImportStmtNode(), helper); case RESOLVED_MODULE_STMT_NODE: return ResolvedModuleStmt.deserialize( proto.getResolvedModuleStmtNode(), helper); case RESOLVED_CREATE_DATABASE_STMT_NODE: return ResolvedCreateDatabaseStmt.deserialize( proto.getResolvedCreateDatabaseStmtNode(), helper); case RESOLVED_ASSERT_STMT_NODE: return ResolvedAssertStmt.deserialize( proto.getResolvedAssertStmtNode(), helper); case RESOLVED_MERGE_STMT_NODE: return ResolvedMergeStmt.deserialize( proto.getResolvedMergeStmtNode(), helper); case RESOLVED_ALTER_OBJECT_STMT_NODE: return ResolvedAlterObjectStmt.deserialize( proto.getResolvedAlterObjectStmtNode(), helper); case RESOLVED_SET_TRANSACTION_STMT_NODE: return ResolvedSetTransactionStmt.deserialize( proto.getResolvedSetTransactionStmtNode(), helper); case RESOLVED_DROP_MATERIALIZED_VIEW_STMT_NODE: return ResolvedDropMaterializedViewStmt.deserialize( proto.getResolvedDropMaterializedViewStmtNode(), helper); case RESOLVED_START_BATCH_STMT_NODE: return ResolvedStartBatchStmt.deserialize( proto.getResolvedStartBatchStmtNode(), helper); case RESOLVED_RUN_BATCH_STMT_NODE: return ResolvedRunBatchStmt.deserialize( proto.getResolvedRunBatchStmtNode(), helper); case RESOLVED_ABORT_BATCH_STMT_NODE: return ResolvedAbortBatchStmt.deserialize( proto.getResolvedAbortBatchStmtNode(), helper); case RESOLVED_TRUNCATE_STMT_NODE: return ResolvedTruncateStmt.deserialize( proto.getResolvedTruncateStmtNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedStatementProto.Builder builder = ResolvedStatementProto.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(); AnyResolvedStatementProto.Builder childBuilder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedStatementNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder); /** * Serializes this node into the given {@link ResolvedStatementProto.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, ResolvedStatementProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedNodeProto parent = (ResolvedNodeProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // 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 ImmutableList getHintList() { return hintList; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(hintList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!hintList.isEmpty()) { fields.add(new DebugStringField("hint_list", hintList)); } } } /** * An Explain statement. This is always the root of a statement hierarchy. * Its child may be any statement type except another ResolvedExplainStmt. * *

It is implementation dependent what action a back end system takes for an * ExplainStatement. */ public static final class ResolvedExplainStmt extends ResolvedStatement { private final ResolvedStatement statement; protected ResolvedExplainStmt(ResolvedExplainStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasStatement()) { statement = ResolvedStatement.deserialize(proto.getStatement(), helper); } else { statement = null; } } public static final ResolvedExplainStmt deserialize( ResolvedExplainStmtProto proto, DeserializationHelper helper) { return new ResolvedExplainStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXPLAIN_STMT; } @Override public final String nodeKindString() { return "ExplainStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedExplainStmtProto.Builder childBuilder = ResolvedExplainStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExplainStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExplainStmtProto.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, ResolvedExplainStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // statement is an AST node. Call its serialization chain. if (this.getStatement() != null) { AnyResolvedStatementProto.Builder statementBuilder = AnyResolvedStatementProto.newBuilder(); this.getStatement().serialize( fileDescriptorSetsBuilder, statementBuilder); proto.setStatement( statementBuilder.build()); } } public final ResolvedStatement getStatement() { return statement; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(statement); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (statement != null) { fields.add(new DebugStringField("statement", statement)); } } } /** * A SQL query statement. This is the outermost query statement that runs * and produces rows of output, like a SELECT. (The contained query may be * a Scan corresponding to a non-Select top-level operation like UNION ALL * or WITH.) * *

gives the user-visible column names that should be * returned in the API or query tools. There may be duplicate names, and * multiple output columns may reference the same column from . */ public static final class ResolvedQueryStmt extends ResolvedStatement { private final ImmutableList outputColumnList; /** * If true, the result of this query is a value table. Rather than * producing rows with named columns, it produces rows with a single * unnamed value type. output_column_list will have exactly one * column, with an empty name. See (broken link). */ private final boolean isValueTable; private final ResolvedScan query; protected ResolvedQueryStmt(ResolvedQueryStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder outputColumnListBuilder = ImmutableList.builder(); for (ResolvedOutputColumnProto element : proto.getOutputColumnListList()) { outputColumnListBuilder .add(ResolvedOutputColumn.deserialize(element, helper)); } outputColumnList = outputColumnListBuilder.build(); isValueTable = proto.getIsValueTable(); if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } } public static final ResolvedQueryStmt deserialize( ResolvedQueryStmtProto proto, DeserializationHelper helper) { return new ResolvedQueryStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_QUERY_STMT; } @Override public final String nodeKindString() { return "QueryStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedQueryStmtProto.Builder childBuilder = ResolvedQueryStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedQueryStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedQueryStmtProto.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, ResolvedQueryStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // outputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList outputColumnLists = this.getOutputColumnList(); for (ResolvedOutputColumn element : outputColumnLists) { ResolvedOutputColumnProto.Builder outputColumnListBuilder = ResolvedOutputColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, outputColumnListBuilder); proto.addOutputColumnList(outputColumnListBuilder.build()); } // isValueTable is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsValueTable(this.getIsValueTable()); // query is an AST node. Call its serialization chain. if (this.getQuery() != null) { AnyResolvedScanProto.Builder queryBuilder = AnyResolvedScanProto.newBuilder(); this.getQuery().serialize( fileDescriptorSetsBuilder, queryBuilder); proto.setQuery( queryBuilder.build()); } } public final ImmutableList getOutputColumnList() { return outputColumnList; } /** * If true, the result of this query is a value table. Rather than * producing rows with named columns, it produces rows with a single * unnamed value type. output_column_list will have exactly one * column, with an empty name. See (broken link). */ public final boolean getIsValueTable() { return isValueTable; } public final ResolvedScan getQuery() { return query; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(outputColumnList); visitor.descend(query); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } if (!DebugStrings.isDefaultValue(isValueTable)) { fields.add(new DebugStringField("is_value_table", DebugStrings.toStringImpl(isValueTable))); } if (query != null) { fields.add(new DebugStringField("query", query)); } } } /** * This statement: * CREATE DATABASE [OPTIONS (...)] * is a vector giving the identifier path in the database name. * specifies the options of the database. */ public static final class ResolvedCreateDatabaseStmt extends ResolvedStatement { private final ImmutableList namePath; private final ImmutableList optionList; protected ResolvedCreateDatabaseStmt(ResolvedCreateDatabaseStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } public static final ResolvedCreateDatabaseStmt deserialize( ResolvedCreateDatabaseStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateDatabaseStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_DATABASE_STMT; } @Override public final String nodeKindString() { return "CreateDatabaseStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedCreateDatabaseStmtProto.Builder childBuilder = ResolvedCreateDatabaseStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateDatabaseStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateDatabaseStmtProto.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, ResolvedCreateDatabaseStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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()); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } } public final ImmutableList getNamePath() { return namePath; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * Common superclass for CREATE statements with standard modifiers like * CREATE [OR REPLACE] [TEMP|TEMPORARY|PUBLIC|PRIVATE] * [IF NOT EXISTS] ... * *

is a vector giving the identifier path in the table name. * is the relevant scope, i.e., DEFAULT, TEMP, PUBLIC, * or PRIVATE. PUBLIC/PRIVATE are only valid in module * resolution context, see (broken link) * for details. * indicates if this was CREATE, CREATE OR REPLACE, or * CREATE IF NOT EXISTS. */ public static abstract class ResolvedCreateStatement extends ResolvedStatement { private final ImmutableList namePath; private final CreateScope createScope; private final CreateMode createMode; protected ResolvedCreateStatement(ResolvedCreateStatementProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); createScope = proto.getCreateScope(); createMode = proto.getCreateMode(); } public static ResolvedCreateStatement deserialize( AnyResolvedCreateStatementProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_CREATE_EXTERNAL_TABLE_STMT_NODE: return ResolvedCreateExternalTableStmt.deserialize( proto.getResolvedCreateExternalTableStmtNode(), helper); case RESOLVED_CREATE_FUNCTION_STMT_NODE: return ResolvedCreateFunctionStmt.deserialize( proto.getResolvedCreateFunctionStmtNode(), helper); case RESOLVED_CREATE_TABLE_FUNCTION_STMT_NODE: return ResolvedCreateTableFunctionStmt.deserialize( proto.getResolvedCreateTableFunctionStmtNode(), helper); case RESOLVED_CREATE_INDEX_STMT_NODE: return ResolvedCreateIndexStmt.deserialize( proto.getResolvedCreateIndexStmtNode(), helper); case RESOLVED_CREATE_CONSTANT_STMT_NODE: return ResolvedCreateConstantStmt.deserialize( proto.getResolvedCreateConstantStmtNode(), helper); case RESOLVED_CREATE_TABLE_STMT_BASE_NODE: return ResolvedCreateTableStmtBase.deserialize( proto.getResolvedCreateTableStmtBaseNode(), helper); case RESOLVED_CREATE_MODEL_STMT_NODE: return ResolvedCreateModelStmt.deserialize( proto.getResolvedCreateModelStmtNode(), helper); case RESOLVED_CREATE_VIEW_BASE_NODE: return ResolvedCreateViewBase.deserialize( proto.getResolvedCreateViewBaseNode(), helper); case RESOLVED_CREATE_PROCEDURE_STMT_NODE: return ResolvedCreateProcedureStmt.deserialize( proto.getResolvedCreateProcedureStmtNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedCreateStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedCreateStatementProto.Builder builder = ResolvedCreateStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); AnyResolvedCreateStatementProto.Builder childBuilder = AnyResolvedCreateStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateStatementNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder); /** * Serializes this node into the given {@link ResolvedCreateStatementProto.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, ResolvedCreateStatementProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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()); // createScope is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setCreateScope(this.getCreateScope()); // createMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setCreateMode(this.getCreateMode()); } public final ImmutableList getNamePath() { return namePath; } public final CreateScope getCreateScope() { return createScope; } public final CreateMode getCreateMode() { return createMode; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(namePath)) { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!DebugStrings.isDefaultValue(createScope)) { fields.add(new DebugStringField("create_scope", DebugStrings.toStringImpl(createScope))); } if (!DebugStrings.isDefaultValue(createMode)) { fields.add(new DebugStringField("create_mode", DebugStrings.toStringImpl(createMode))); } } } /** * Represents one of indexed items in CREATE INDEX statement, with the * ordering direction specified. */ public static final class ResolvedIndexItem extends ResolvedArgument { private final ResolvedColumnRef columnRef; private final boolean descending; protected ResolvedIndexItem(ResolvedIndexItemProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasColumnRef()) { columnRef = ResolvedColumnRef.deserialize(proto.getColumnRef(), helper); } else { columnRef = null; } descending = proto.getDescending(); } public static final ResolvedIndexItem deserialize( ResolvedIndexItemProto proto, DeserializationHelper helper) { return new ResolvedIndexItem(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_INDEX_ITEM; } @Override public final String nodeKindString() { return "IndexItem"; } /** * 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(); ResolvedIndexItemProto.Builder childBuilder = ResolvedIndexItemProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedIndexItemNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedIndexItemProto.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, ResolvedIndexItemProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // columnRef is an AST node. Call its serialization chain. if (this.getColumnRef() != null) { ResolvedColumnRefProto.Builder columnRefBuilder = ResolvedColumnRefProto.newBuilder(); this.getColumnRef().serialize( fileDescriptorSetsBuilder, columnRefBuilder); proto.setColumnRef( columnRefBuilder.build()); } // descending is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setDescending(this.getDescending()); } public final ResolvedColumnRef getColumnRef() { return columnRef; } public final boolean getDescending() { return descending; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnRef); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (columnRef != null) { fields.add(new DebugStringField("column_ref", columnRef)); } { fields.add(new DebugStringField("descending", DebugStrings.toStringImpl(descending))); } } } /** * This is used in CREATE INDEX STMT to represent the unnest operation * performed on the base table. The produced element columns or array offset * columns (optional) can appear in other ResolvedUnnestItem or index keys. * *

is the expression of the array field, e.g., t.array_field. * is the new column produced by this unnest item that * stores the array element value for each row. * is optional. If present, it defines the column * produced by this unnest item that stores the array * offset (0-based) for the corresponding * . */ public static final class ResolvedUnnestItem extends ResolvedArgument { private final ResolvedExpr arrayExpr; private final ResolvedColumn elementColumn; private final ResolvedColumnHolder arrayOffsetColumn; protected ResolvedUnnestItem(ResolvedUnnestItemProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasArrayExpr()) { arrayExpr = ResolvedExpr.deserialize(proto.getArrayExpr(), helper); } else { arrayExpr = null; } elementColumn = helper.deserialize(proto.getElementColumn()); if (proto.hasArrayOffsetColumn()) { arrayOffsetColumn = ResolvedColumnHolder.deserialize(proto.getArrayOffsetColumn(), helper); } else { arrayOffsetColumn = null; } } public static final ResolvedUnnestItem deserialize( ResolvedUnnestItemProto proto, DeserializationHelper helper) { return new ResolvedUnnestItem(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_UNNEST_ITEM; } @Override public final String nodeKindString() { return "UnnestItem"; } /** * 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(); ResolvedUnnestItemProto.Builder childBuilder = ResolvedUnnestItemProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedUnnestItemNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedUnnestItemProto.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, ResolvedUnnestItemProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // arrayExpr is an AST node. Call its serialization chain. if (this.getArrayExpr() != null) { AnyResolvedExprProto.Builder arrayExprBuilder = AnyResolvedExprProto.newBuilder(); this.getArrayExpr().serialize( fileDescriptorSetsBuilder, arrayExprBuilder); proto.setArrayExpr( arrayExprBuilder.build()); } // elementColumn is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getElementColumn() != null) { proto.setElementColumn( ResolvedNodes.serialize(this.getElementColumn(), fileDescriptorSetsBuilder)); } // arrayOffsetColumn is an AST node. Call its serialization chain. if (this.getArrayOffsetColumn() != null) { ResolvedColumnHolderProto.Builder arrayOffsetColumnBuilder = ResolvedColumnHolderProto.newBuilder(); this.getArrayOffsetColumn().serialize( fileDescriptorSetsBuilder, arrayOffsetColumnBuilder); proto.setArrayOffsetColumn( arrayOffsetColumnBuilder.build()); } } public final ResolvedExpr getArrayExpr() { return arrayExpr; } public final ResolvedColumn getElementColumn() { return elementColumn; } public final ResolvedColumnHolder getArrayOffsetColumn() { return arrayOffsetColumn; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(arrayExpr); visitor.descend(arrayOffsetColumn); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (arrayExpr != null) { fields.add(new DebugStringField("array_expr", arrayExpr)); } { fields.add(new DebugStringField("element_column", DebugStrings.toStringImpl(elementColumn))); } if (arrayOffsetColumn != null) { fields.add(new DebugStringField("array_offset_column", arrayOffsetColumn)); } } } /** * This statement: * CREATE [OR REPLACE] [UNIQUE] INDEX [IF NOT EXISTS] * ON * [STORING (Expression, ...)] * [UNNEST(path_expression) [[AS] alias] [WITH OFFSET [[AS] alias]], ...] * (path_expression [ASC|DESC], ...) [OPTIONS (name=value, ...)]; * *

is the name of table being indexed. * is a TableScan on the table being indexed. * specifies if the index has unique entries. * has the columns being indexed, specified as references * to 'computed_columns_list' entries or the columns of * 'table_scan'. * has the expressions in the storing clause. * has engine-specific directives for how and where to * materialize this index. * has computed columns derived from the columns of * 'table_scan' or 'unnest_expressions_list'. For * example, the extracted field (e.g., x.y.z). * has unnest expressions derived from * 'table_scan' or previous unnest expressions in * the list. So the list order is significant. */ public static final class ResolvedCreateIndexStmt extends ResolvedCreateStatement { private final ImmutableList tableNamePath; private final ResolvedTableScan tableScan; private final boolean isUnique; private final ImmutableList indexItemList; private final ImmutableList storingExpressionList; private final ImmutableList optionList; private final ImmutableList computedColumnsList; private final ImmutableList unnestExpressionsList; protected ResolvedCreateIndexStmt(ResolvedCreateIndexStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); tableNamePath = ImmutableList.copyOf(proto.getTableNamePathList()); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } isUnique = proto.getIsUnique(); ImmutableList.Builder indexItemListBuilder = ImmutableList.builder(); for (ResolvedIndexItemProto element : proto.getIndexItemListList()) { indexItemListBuilder .add(ResolvedIndexItem.deserialize(element, helper)); } indexItemList = indexItemListBuilder.build(); ImmutableList.Builder storingExpressionListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getStoringExpressionListList()) { storingExpressionListBuilder .add(ResolvedExpr.deserialize(element, helper)); } storingExpressionList = storingExpressionListBuilder.build(); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); ImmutableList.Builder computedColumnsListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getComputedColumnsListList()) { computedColumnsListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } computedColumnsList = computedColumnsListBuilder.build(); ImmutableList.Builder unnestExpressionsListBuilder = ImmutableList.builder(); for (ResolvedUnnestItemProto element : proto.getUnnestExpressionsListList()) { unnestExpressionsListBuilder .add(ResolvedUnnestItem.deserialize(element, helper)); } unnestExpressionsList = unnestExpressionsListBuilder.build(); } public static final ResolvedCreateIndexStmt deserialize( ResolvedCreateIndexStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateIndexStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_INDEX_STMT; } @Override public final String nodeKindString() { return "CreateIndexStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateStatementProto.Builder builder = AnyResolvedCreateStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder) { builder.clear(); ResolvedCreateIndexStmtProto.Builder childBuilder = ResolvedCreateIndexStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateIndexStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateIndexStmtProto.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, ResolvedCreateIndexStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // tableNamePath 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.addAllTableNamePath(this.getTableNamePath()); // tableScan is an AST node. Call its serialization chain. if (this.getTableScan() != null) { ResolvedTableScanProto.Builder tableScanBuilder = ResolvedTableScanProto.newBuilder(); this.getTableScan().serialize( fileDescriptorSetsBuilder, tableScanBuilder); proto.setTableScan( tableScanBuilder.build()); } // isUnique is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsUnique(this.getIsUnique()); // indexItemList is a collection of AST nodes. Serialize each of them. ImmutableList indexItemLists = this.getIndexItemList(); for (ResolvedIndexItem element : indexItemLists) { ResolvedIndexItemProto.Builder indexItemListBuilder = ResolvedIndexItemProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, indexItemListBuilder); proto.addIndexItemList(indexItemListBuilder.build()); } // storingExpressionList is a collection of AST nodes. Serialize each of them. ImmutableList storingExpressionLists = this.getStoringExpressionList(); for (ResolvedExpr element : storingExpressionLists) { AnyResolvedExprProto.Builder storingExpressionListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, storingExpressionListBuilder); proto.addStoringExpressionList(storingExpressionListBuilder.build()); } // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // computedColumnsList is a collection of AST nodes. Serialize each of them. ImmutableList computedColumnsLists = this.getComputedColumnsList(); for (ResolvedComputedColumn element : computedColumnsLists) { ResolvedComputedColumnProto.Builder computedColumnsListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, computedColumnsListBuilder); proto.addComputedColumnsList(computedColumnsListBuilder.build()); } // unnestExpressionsList is a collection of AST nodes. Serialize each of them. ImmutableList unnestExpressionsLists = this.getUnnestExpressionsList(); for (ResolvedUnnestItem element : unnestExpressionsLists) { ResolvedUnnestItemProto.Builder unnestExpressionsListBuilder = ResolvedUnnestItemProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, unnestExpressionsListBuilder); proto.addUnnestExpressionsList(unnestExpressionsListBuilder.build()); } } public final ImmutableList getTableNamePath() { return tableNamePath; } public final ResolvedTableScan getTableScan() { return tableScan; } public final boolean getIsUnique() { return isUnique; } public final ImmutableList getIndexItemList() { return indexItemList; } public final ImmutableList getStoringExpressionList() { return storingExpressionList; } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getComputedColumnsList() { return computedColumnsList; } public final ImmutableList getUnnestExpressionsList() { return unnestExpressionsList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(indexItemList); visitor.descend(storingExpressionList); visitor.descend(optionList); visitor.descend(computedColumnsList); visitor.descend(unnestExpressionsList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("table_name_path", DebugStrings.toStringImpl(tableNamePath))); } if (tableScan != null) { fields.add(new DebugStringField("table_scan", tableScan)); } { fields.add(new DebugStringField("is_unique", DebugStrings.toStringImpl(isUnique))); } if (!indexItemList.isEmpty()) { fields.add(new DebugStringField("index_item_list", indexItemList)); } if (!storingExpressionList.isEmpty()) { fields.add(new DebugStringField("storing_expression_list", storingExpressionList)); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!computedColumnsList.isEmpty()) { fields.add(new DebugStringField("computed_columns_list", computedColumnsList)); } if (!unnestExpressionsList.isEmpty()) { fields.add(new DebugStringField("unnest_expressions_list", unnestExpressionsList)); } } } /** * This statement: * CREATE [TEMP] TABLE (column type, ...) * [PARTITION BY expr, ...] [CLUSTER BY expr, ...] * [OPTIONS (...)] * *

has engine-specific directives for how and where to * materialize this table. * has the names and types of the columns in the * created table. If is true, it * must contain exactly one column, with a generated * name such as "$struct". * is a list of some pseudo-columns expected to be * present on the created table (provided by * AnalyzerOptions::SetDdlPseudoColumns*). These can be * referenced in expressions in and * . * specifies the PRIMARY KEY constraint on the table, it is * nullptr when no PRIMARY KEY is specified. * specifies the FOREIGN KEY constraints on the table. * specifies the CHECK constraints on the table. * specifies the partitioning expressions for the table. * specifies the clustering expressions for the table. * specifies whether the table is a value table. * See (broken link). */ public static abstract class ResolvedCreateTableStmtBase extends ResolvedCreateStatement { private final ImmutableList optionList; private final ImmutableList columnDefinitionList; private final ImmutableList pseudoColumnList; private final ResolvedPrimaryKey primaryKey; private final ImmutableList foreignKeyList; private final ImmutableList checkConstraintList; private final ImmutableList partitionByList; private final ImmutableList clusterByList; private final boolean isValueTable; protected ResolvedCreateTableStmtBase(ResolvedCreateTableStmtBaseProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); ImmutableList.Builder columnDefinitionListBuilder = ImmutableList.builder(); for (ResolvedColumnDefinitionProto element : proto.getColumnDefinitionListList()) { columnDefinitionListBuilder .add(ResolvedColumnDefinition.deserialize(element, helper)); } columnDefinitionList = columnDefinitionListBuilder.build(); ImmutableList.Builder pseudoColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getPseudoColumnListList()) { pseudoColumnListBuilder.add(helper.deserialize(element)); } pseudoColumnList = pseudoColumnListBuilder.build(); if (proto.hasPrimaryKey()) { primaryKey = ResolvedPrimaryKey.deserialize(proto.getPrimaryKey(), helper); } else { primaryKey = null; } ImmutableList.Builder foreignKeyListBuilder = ImmutableList.builder(); for (ResolvedForeignKeyProto element : proto.getForeignKeyListList()) { foreignKeyListBuilder .add(ResolvedForeignKey.deserialize(element, helper)); } foreignKeyList = foreignKeyListBuilder.build(); ImmutableList.Builder checkConstraintListBuilder = ImmutableList.builder(); for (ResolvedCheckConstraintProto element : proto.getCheckConstraintListList()) { checkConstraintListBuilder .add(ResolvedCheckConstraint.deserialize(element, helper)); } checkConstraintList = checkConstraintListBuilder.build(); ImmutableList.Builder partitionByListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getPartitionByListList()) { partitionByListBuilder .add(ResolvedExpr.deserialize(element, helper)); } partitionByList = partitionByListBuilder.build(); ImmutableList.Builder clusterByListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getClusterByListList()) { clusterByListBuilder .add(ResolvedExpr.deserialize(element, helper)); } clusterByList = clusterByListBuilder.build(); isValueTable = proto.getIsValueTable(); } public static ResolvedCreateTableStmtBase deserialize( AnyResolvedCreateTableStmtBaseProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_CREATE_TABLE_AS_SELECT_STMT_NODE: return ResolvedCreateTableAsSelectStmt.deserialize( proto.getResolvedCreateTableAsSelectStmtNode(), helper); case RESOLVED_CREATE_TABLE_STMT_NODE: return ResolvedCreateTableStmt.deserialize( proto.getResolvedCreateTableStmtNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedCreateTableStmtBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedCreateTableStmtBaseProto.Builder builder = ResolvedCreateTableStmtBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder) { builder.clear(); AnyResolvedCreateTableStmtBaseProto.Builder childBuilder = AnyResolvedCreateTableStmtBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateTableStmtBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedCreateTableStmtBaseProto.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, AnyResolvedCreateTableStmtBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedCreateTableStmtBaseProto.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, ResolvedCreateTableStmtBaseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // columnDefinitionList is a collection of AST nodes. Serialize each of them. ImmutableList columnDefinitionLists = this.getColumnDefinitionList(); for (ResolvedColumnDefinition element : columnDefinitionLists) { ResolvedColumnDefinitionProto.Builder columnDefinitionListBuilder = ResolvedColumnDefinitionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, columnDefinitionListBuilder); proto.addColumnDefinitionList(columnDefinitionListBuilder.build()); } // pseudoColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList pseudoColumnLists = this.getPseudoColumnList(); for (ResolvedColumn element : pseudoColumnLists) { proto.addPseudoColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // primaryKey is an AST node. Call its serialization chain. if (this.getPrimaryKey() != null) { ResolvedPrimaryKeyProto.Builder primaryKeyBuilder = ResolvedPrimaryKeyProto.newBuilder(); this.getPrimaryKey().serialize( fileDescriptorSetsBuilder, primaryKeyBuilder); proto.setPrimaryKey( primaryKeyBuilder.build()); } // foreignKeyList is a collection of AST nodes. Serialize each of them. ImmutableList foreignKeyLists = this.getForeignKeyList(); for (ResolvedForeignKey element : foreignKeyLists) { ResolvedForeignKeyProto.Builder foreignKeyListBuilder = ResolvedForeignKeyProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, foreignKeyListBuilder); proto.addForeignKeyList(foreignKeyListBuilder.build()); } // checkConstraintList is a collection of AST nodes. Serialize each of them. ImmutableList checkConstraintLists = this.getCheckConstraintList(); for (ResolvedCheckConstraint element : checkConstraintLists) { ResolvedCheckConstraintProto.Builder checkConstraintListBuilder = ResolvedCheckConstraintProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, checkConstraintListBuilder); proto.addCheckConstraintList(checkConstraintListBuilder.build()); } // partitionByList is a collection of AST nodes. Serialize each of them. ImmutableList partitionByLists = this.getPartitionByList(); for (ResolvedExpr element : partitionByLists) { AnyResolvedExprProto.Builder partitionByListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, partitionByListBuilder); proto.addPartitionByList(partitionByListBuilder.build()); } // clusterByList is a collection of AST nodes. Serialize each of them. ImmutableList clusterByLists = this.getClusterByList(); for (ResolvedExpr element : clusterByLists) { AnyResolvedExprProto.Builder clusterByListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, clusterByListBuilder); proto.addClusterByList(clusterByListBuilder.build()); } // isValueTable is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsValueTable(this.getIsValueTable()); } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getColumnDefinitionList() { return columnDefinitionList; } public final ImmutableList getPseudoColumnList() { return pseudoColumnList; } public final ResolvedPrimaryKey getPrimaryKey() { return primaryKey; } public final ImmutableList getForeignKeyList() { return foreignKeyList; } public final ImmutableList getCheckConstraintList() { return checkConstraintList; } public final ImmutableList getPartitionByList() { return partitionByList; } public final ImmutableList getClusterByList() { return clusterByList; } public final boolean getIsValueTable() { return isValueTable; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(columnDefinitionList); visitor.descend(primaryKey); visitor.descend(foreignKeyList); visitor.descend(checkConstraintList); visitor.descend(partitionByList); visitor.descend(clusterByList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!columnDefinitionList.isEmpty()) { fields.add(new DebugStringField("column_definition_list", columnDefinitionList)); } if (!DebugStrings.isDefaultValue(pseudoColumnList)) { fields.add(new DebugStringField("pseudo_column_list", DebugStrings.toStringImpl(pseudoColumnList))); } if (primaryKey != null) { fields.add(new DebugStringField("primary_key", primaryKey)); } if (!foreignKeyList.isEmpty()) { fields.add(new DebugStringField("foreign_key_list", foreignKeyList)); } if (!checkConstraintList.isEmpty()) { fields.add(new DebugStringField("check_constraint_list", checkConstraintList)); } if (!partitionByList.isEmpty()) { fields.add(new DebugStringField("partition_by_list", partitionByList)); } if (!clusterByList.isEmpty()) { fields.add(new DebugStringField("cluster_by_list", clusterByList)); } if (!DebugStrings.isDefaultValue(isValueTable)) { fields.add(new DebugStringField("is_value_table", DebugStrings.toStringImpl(isValueTable))); } } } /** * This statement: * CREATE [TEMP] TABLE (column schema, ...) * [PARTITION BY expr, ...] [CLUSTER BY expr, ...] * [OPTIONS (...)] */ public static final class ResolvedCreateTableStmt extends ResolvedCreateTableStmtBase { protected ResolvedCreateTableStmt(ResolvedCreateTableStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedCreateTableStmt deserialize( ResolvedCreateTableStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateTableStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_TABLE_STMT; } @Override public final String nodeKindString() { return "CreateTableStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateTableStmtBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateTableStmtBaseProto.Builder builder = AnyResolvedCreateTableStmtBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateTableStmtBaseProto.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, AnyResolvedCreateTableStmtBaseProto.Builder builder) { builder.clear(); ResolvedCreateTableStmtProto.Builder childBuilder = ResolvedCreateTableStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateTableStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateTableStmtProto.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, ResolvedCreateTableStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateTableStmtBaseProto parent = (ResolvedCreateTableStmtBaseProto) 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); } } /** * This statement: * CREATE [TEMP] TABLE [(column schema, ...)] * [PARTITION BY expr, ...] [CLUSTER BY expr, ...] [OPTIONS (...)] * AS SELECT ... * *

The matches 1:1 with the in * ResolvedCreateTableStmtBase, and maps ResolvedColumns produced by * into specific columns of the created table. The output column names and * types must match the column definition names and types. If the table is * a value table, must have exactly one column, with a * generated name such as "$struct". * *

does not contain all table schema information that * does. For example, NOT NULL annotations, column * OPTIONS, and primary keys are only available in . * Consumers are encouraged to read from rather * than than to determine the table schema, if possible. * *

is the query to run. */ public static final class ResolvedCreateTableAsSelectStmt extends ResolvedCreateTableStmtBase { private final ImmutableList outputColumnList; private final ResolvedScan query; protected ResolvedCreateTableAsSelectStmt(ResolvedCreateTableAsSelectStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder outputColumnListBuilder = ImmutableList.builder(); for (ResolvedOutputColumnProto element : proto.getOutputColumnListList()) { outputColumnListBuilder .add(ResolvedOutputColumn.deserialize(element, helper)); } outputColumnList = outputColumnListBuilder.build(); if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } } public static final ResolvedCreateTableAsSelectStmt deserialize( ResolvedCreateTableAsSelectStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateTableAsSelectStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_TABLE_AS_SELECT_STMT; } @Override public final String nodeKindString() { return "CreateTableAsSelectStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateTableStmtBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateTableStmtBaseProto.Builder builder = AnyResolvedCreateTableStmtBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateTableStmtBaseProto.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, AnyResolvedCreateTableStmtBaseProto.Builder builder) { builder.clear(); ResolvedCreateTableAsSelectStmtProto.Builder childBuilder = ResolvedCreateTableAsSelectStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateTableAsSelectStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateTableAsSelectStmtProto.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, ResolvedCreateTableAsSelectStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateTableStmtBaseProto parent = (ResolvedCreateTableStmtBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // outputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList outputColumnLists = this.getOutputColumnList(); for (ResolvedOutputColumn element : outputColumnLists) { ResolvedOutputColumnProto.Builder outputColumnListBuilder = ResolvedOutputColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, outputColumnListBuilder); proto.addOutputColumnList(outputColumnListBuilder.build()); } // query is an AST node. Call its serialization chain. if (this.getQuery() != null) { AnyResolvedScanProto.Builder queryBuilder = AnyResolvedScanProto.newBuilder(); this.getQuery().serialize( fileDescriptorSetsBuilder, queryBuilder); proto.setQuery( queryBuilder.build()); } } public final ImmutableList getOutputColumnList() { return outputColumnList; } public final ResolvedScan getQuery() { return query; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(outputColumnList); visitor.descend(query); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } if (query != null) { fields.add(new DebugStringField("query", query)); } } } /** * This statement: * CREATE [TEMP] MODEL [TRANSFORM(...)] [OPTIONS (...)] AS SELECT .. * *

has engine-specific directives for how to train this model. * matches 1:1 with the 's column_list and the * , and identifies the names * and types of the columns output from the select * statement. * is the select statement. * introduces new ResolvedColumns that have the * same names and types of the columns in the . The * transform expressions resolve against these ResolvedColumns. It's only * set when is non-empty. * is the list of ResolvedComputedColumn in TRANSFORM * clause. * matches 1:1 with output. * It records the names of the output columns from TRANSFORM clause. * is the list of * AnalyticFunctionGroup for analytic functions inside TRANSFORM clause. * It records the input expression of the analytic functions. It can * see all the columns from . The only valid * group is for the full, unbounded window generated from empty OVER() * clause. * For example, CREATE MODEL statement * "create model Z * transform (max(c) over() as d) * options () * as select 1 c, 2 b;" * will generate transform_analytic_function_group_list: * +-transform_analytic_function_group_list= * +-AnalyticFunctionGroup * +-analytic_function_list= * +-d#5 := * +-AnalyticFunctionCall(ZetaSQL:max(INT64) -> INT64) * +-ColumnRef(type=INT64, column=Z.c#3) * +-window_frame= * +-WindowFrame(frame_unit=ROWS) * +-start_expr= * | +-WindowFrameExpr(boundary_type=UNBOUNDED PRECEDING) * +-end_expr= * +-WindowFrameExpr(boundary_type=UNBOUNDED FOLLOWING) */ public static final class ResolvedCreateModelStmt extends ResolvedCreateStatement { private final ImmutableList optionList; private final ImmutableList outputColumnList; private final ResolvedScan query; private final ImmutableList transformInputColumnList; private final ImmutableList transformList; private final ImmutableList transformOutputColumnList; private final ImmutableList transformAnalyticFunctionGroupList; protected ResolvedCreateModelStmt(ResolvedCreateModelStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); ImmutableList.Builder outputColumnListBuilder = ImmutableList.builder(); for (ResolvedOutputColumnProto element : proto.getOutputColumnListList()) { outputColumnListBuilder .add(ResolvedOutputColumn.deserialize(element, helper)); } outputColumnList = outputColumnListBuilder.build(); if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } ImmutableList.Builder transformInputColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnDefinitionProto element : proto.getTransformInputColumnListList()) { transformInputColumnListBuilder .add(ResolvedColumnDefinition.deserialize(element, helper)); } transformInputColumnList = transformInputColumnListBuilder.build(); ImmutableList.Builder transformListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getTransformListList()) { transformListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } transformList = transformListBuilder.build(); ImmutableList.Builder transformOutputColumnListBuilder = ImmutableList.builder(); for (ResolvedOutputColumnProto element : proto.getTransformOutputColumnListList()) { transformOutputColumnListBuilder .add(ResolvedOutputColumn.deserialize(element, helper)); } transformOutputColumnList = transformOutputColumnListBuilder.build(); ImmutableList.Builder transformAnalyticFunctionGroupListBuilder = ImmutableList.builder(); for (ResolvedAnalyticFunctionGroupProto element : proto.getTransformAnalyticFunctionGroupListList()) { transformAnalyticFunctionGroupListBuilder .add(ResolvedAnalyticFunctionGroup.deserialize(element, helper)); } transformAnalyticFunctionGroupList = transformAnalyticFunctionGroupListBuilder.build(); } public static final ResolvedCreateModelStmt deserialize( ResolvedCreateModelStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateModelStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_MODEL_STMT; } @Override public final String nodeKindString() { return "CreateModelStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateStatementProto.Builder builder = AnyResolvedCreateStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder) { builder.clear(); ResolvedCreateModelStmtProto.Builder childBuilder = ResolvedCreateModelStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateModelStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateModelStmtProto.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, ResolvedCreateModelStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // outputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList outputColumnLists = this.getOutputColumnList(); for (ResolvedOutputColumn element : outputColumnLists) { ResolvedOutputColumnProto.Builder outputColumnListBuilder = ResolvedOutputColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, outputColumnListBuilder); proto.addOutputColumnList(outputColumnListBuilder.build()); } // query is an AST node. Call its serialization chain. if (this.getQuery() != null) { AnyResolvedScanProto.Builder queryBuilder = AnyResolvedScanProto.newBuilder(); this.getQuery().serialize( fileDescriptorSetsBuilder, queryBuilder); proto.setQuery( queryBuilder.build()); } // transformInputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList transformInputColumnLists = this.getTransformInputColumnList(); for (ResolvedColumnDefinition element : transformInputColumnLists) { ResolvedColumnDefinitionProto.Builder transformInputColumnListBuilder = ResolvedColumnDefinitionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, transformInputColumnListBuilder); proto.addTransformInputColumnList(transformInputColumnListBuilder.build()); } // transformList is a collection of AST nodes. Serialize each of them. ImmutableList transformLists = this.getTransformList(); for (ResolvedComputedColumn element : transformLists) { ResolvedComputedColumnProto.Builder transformListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, transformListBuilder); proto.addTransformList(transformListBuilder.build()); } // transformOutputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList transformOutputColumnLists = this.getTransformOutputColumnList(); for (ResolvedOutputColumn element : transformOutputColumnLists) { ResolvedOutputColumnProto.Builder transformOutputColumnListBuilder = ResolvedOutputColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, transformOutputColumnListBuilder); proto.addTransformOutputColumnList(transformOutputColumnListBuilder.build()); } // transformAnalyticFunctionGroupList is a collection of AST nodes. Serialize each of them. ImmutableList transformAnalyticFunctionGroupLists = this.getTransformAnalyticFunctionGroupList(); for (ResolvedAnalyticFunctionGroup element : transformAnalyticFunctionGroupLists) { ResolvedAnalyticFunctionGroupProto.Builder transformAnalyticFunctionGroupListBuilder = ResolvedAnalyticFunctionGroupProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, transformAnalyticFunctionGroupListBuilder); proto.addTransformAnalyticFunctionGroupList(transformAnalyticFunctionGroupListBuilder.build()); } } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getOutputColumnList() { return outputColumnList; } public final ResolvedScan getQuery() { return query; } public final ImmutableList getTransformInputColumnList() { return transformInputColumnList; } public final ImmutableList getTransformList() { return transformList; } public final ImmutableList getTransformOutputColumnList() { return transformOutputColumnList; } public final ImmutableList getTransformAnalyticFunctionGroupList() { return transformAnalyticFunctionGroupList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(outputColumnList); visitor.descend(query); visitor.descend(transformInputColumnList); visitor.descend(transformList); visitor.descend(transformOutputColumnList); visitor.descend(transformAnalyticFunctionGroupList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } if (query != null) { fields.add(new DebugStringField("query", query)); } if (!transformInputColumnList.isEmpty()) { fields.add(new DebugStringField("transform_input_column_list", transformInputColumnList)); } if (!transformList.isEmpty()) { fields.add(new DebugStringField("transform_list", transformList)); } if (!transformOutputColumnList.isEmpty()) { fields.add(new DebugStringField("transform_output_column_list", transformOutputColumnList)); } if (!transformAnalyticFunctionGroupList.isEmpty()) { fields.add(new DebugStringField("transform_analytic_function_group_list", transformAnalyticFunctionGroupList)); } } } /** * Common superclass for CREATE view/materialized view: * CREATE [TEMP|MATERIALIZED] VIEW [OPTIONS (...)] AS SELECT ... * *

has engine-specific directives for options attached to * this view. * has the names and types of the columns in the * created view, and maps from 's column_list * to these output columns. * is the query to run. * is the view query text. * is the declared security mode for the function. Values * include 'INVOKER', 'DEFINER'. * *

Note that and are both marked as IGNORABLE because * an engine could look at either one (but might not look at both). * An engine must look at one (and cannot ignore both) to be * semantically valid, but there is currently no way to enforce that. * *

The view must produce named columns with unique names. */ public static abstract class ResolvedCreateViewBase extends ResolvedCreateStatement { private final ImmutableList optionList; private final ImmutableList outputColumnList; private final ResolvedScan query; private final String sql; private final SqlSecurity sqlSecurity; /** * If true, this view produces a value table. Rather than producing * rows with named columns, it produces rows with a single unnamed * value type. output_column_list will have exactly one column, with * an empty name. See (broken link). */ private final boolean isValueTable; protected ResolvedCreateViewBase(ResolvedCreateViewBaseProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); ImmutableList.Builder outputColumnListBuilder = ImmutableList.builder(); for (ResolvedOutputColumnProto element : proto.getOutputColumnListList()) { outputColumnListBuilder .add(ResolvedOutputColumn.deserialize(element, helper)); } outputColumnList = outputColumnListBuilder.build(); if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } sql = proto.getSql(); sqlSecurity = proto.getSqlSecurity(); isValueTable = proto.getIsValueTable(); } public static ResolvedCreateViewBase deserialize( AnyResolvedCreateViewBaseProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_CREATE_VIEW_STMT_NODE: return ResolvedCreateViewStmt.deserialize( proto.getResolvedCreateViewStmtNode(), helper); case RESOLVED_CREATE_MATERIALIZED_VIEW_STMT_NODE: return ResolvedCreateMaterializedViewStmt.deserialize( proto.getResolvedCreateMaterializedViewStmtNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedCreateViewBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedCreateViewBaseProto.Builder builder = ResolvedCreateViewBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder) { builder.clear(); AnyResolvedCreateViewBaseProto.Builder childBuilder = AnyResolvedCreateViewBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateViewBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedCreateViewBaseProto.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, AnyResolvedCreateViewBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedCreateViewBaseProto.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, ResolvedCreateViewBaseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // outputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList outputColumnLists = this.getOutputColumnList(); for (ResolvedOutputColumn element : outputColumnLists) { ResolvedOutputColumnProto.Builder outputColumnListBuilder = ResolvedOutputColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, outputColumnListBuilder); proto.addOutputColumnList(outputColumnListBuilder.build()); } // query is an AST node. Call its serialization chain. if (this.getQuery() != null) { AnyResolvedScanProto.Builder queryBuilder = AnyResolvedScanProto.newBuilder(); this.getQuery().serialize( fileDescriptorSetsBuilder, queryBuilder); proto.setQuery( queryBuilder.build()); } // sql is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setSql(this.getSql()); // sqlSecurity is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setSqlSecurity(this.getSqlSecurity()); // isValueTable is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsValueTable(this.getIsValueTable()); } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getOutputColumnList() { return outputColumnList; } public final ResolvedScan getQuery() { return query; } public final String getSql() { return sql; } public final SqlSecurity getSqlSecurity() { return sqlSecurity; } /** * If true, this view produces a value table. Rather than producing * rows with named columns, it produces rows with a single unnamed * value type. output_column_list will have exactly one column, with * an empty name. See (broken link). */ public final boolean getIsValueTable() { return isValueTable; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(outputColumnList); visitor.descend(query); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } if (query != null) { fields.add(new DebugStringField("query", query)); } if (!DebugStrings.isDefaultValue(sql)) { fields.add(new DebugStringField("sql", DebugStrings.toStringImpl(sql))); } if (!DebugStrings.isDefaultValue(sqlSecurity)) { fields.add(new DebugStringField("sql_security", DebugStrings.toStringImpl(sqlSecurity))); } if (!DebugStrings.isDefaultValue(isValueTable)) { fields.add(new DebugStringField("is_value_table", DebugStrings.toStringImpl(isValueTable))); } } } /** * This statement: * CREATE [TEMP] VIEW [OPTIONS (...)] AS SELECT ... */ public static final class ResolvedCreateViewStmt extends ResolvedCreateViewBase { protected ResolvedCreateViewStmt(ResolvedCreateViewStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedCreateViewStmt deserialize( ResolvedCreateViewStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateViewStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_VIEW_STMT; } @Override public final String nodeKindString() { return "CreateViewStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateViewBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateViewBaseProto.Builder builder = AnyResolvedCreateViewBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateViewBaseProto.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, AnyResolvedCreateViewBaseProto.Builder builder) { builder.clear(); ResolvedCreateViewStmtProto.Builder childBuilder = ResolvedCreateViewStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateViewStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateViewStmtProto.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, ResolvedCreateViewStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateViewBaseProto parent = (ResolvedCreateViewBaseProto) 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); } } /** * This statement: * CREATE [TEMP] EXTERNAL TABLE OPTIONS (...) * *

has engine-specific directives that specify how to * produce data for this external table. */ public static final class ResolvedCreateExternalTableStmt extends ResolvedCreateStatement { private final ImmutableList optionList; protected ResolvedCreateExternalTableStmt(ResolvedCreateExternalTableStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } public static final ResolvedCreateExternalTableStmt deserialize( ResolvedCreateExternalTableStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateExternalTableStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_EXTERNAL_TABLE_STMT; } @Override public final String nodeKindString() { return "CreateExternalTableStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateStatementProto.Builder builder = AnyResolvedCreateStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder) { builder.clear(); ResolvedCreateExternalTableStmtProto.Builder childBuilder = ResolvedCreateExternalTableStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateExternalTableStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateExternalTableStmtProto.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, ResolvedCreateExternalTableStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This statement: * EXPORT DATA () AS SELECT ... * which is used to run a query and export its result somewhere * without giving the result a table name. * *

has engine-specific directives for how and where to * materialize the query result. * has the names and types of the columns produced by * the query, and maps from 's column_list * to these output columns. The engine may ignore * the column names depending on the output format. * is the query to run. * *

The query must produce named columns with unique names. */ public static final class ResolvedExportDataStmt extends ResolvedStatement { private final ImmutableList optionList; private final ImmutableList outputColumnList; /** * If true, the result of this query is a value table. Rather than * producing rows with named columns, it produces rows with a single * unnamed value type. output_column_list will have exactly one * column, with an empty name. See (broken link). */ private final boolean isValueTable; private final ResolvedScan query; protected ResolvedExportDataStmt(ResolvedExportDataStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); ImmutableList.Builder outputColumnListBuilder = ImmutableList.builder(); for (ResolvedOutputColumnProto element : proto.getOutputColumnListList()) { outputColumnListBuilder .add(ResolvedOutputColumn.deserialize(element, helper)); } outputColumnList = outputColumnListBuilder.build(); isValueTable = proto.getIsValueTable(); if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } } public static final ResolvedExportDataStmt deserialize( ResolvedExportDataStmtProto proto, DeserializationHelper helper) { return new ResolvedExportDataStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXPORT_DATA_STMT; } @Override public final String nodeKindString() { return "ExportDataStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedExportDataStmtProto.Builder childBuilder = ResolvedExportDataStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExportDataStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExportDataStmtProto.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, ResolvedExportDataStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // outputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList outputColumnLists = this.getOutputColumnList(); for (ResolvedOutputColumn element : outputColumnLists) { ResolvedOutputColumnProto.Builder outputColumnListBuilder = ResolvedOutputColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, outputColumnListBuilder); proto.addOutputColumnList(outputColumnListBuilder.build()); } // isValueTable is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsValueTable(this.getIsValueTable()); // query is an AST node. Call its serialization chain. if (this.getQuery() != null) { AnyResolvedScanProto.Builder queryBuilder = AnyResolvedScanProto.newBuilder(); this.getQuery().serialize( fileDescriptorSetsBuilder, queryBuilder); proto.setQuery( queryBuilder.build()); } } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getOutputColumnList() { return outputColumnList; } /** * If true, the result of this query is a value table. Rather than * producing rows with named columns, it produces rows with a single * unnamed value type. output_column_list will have exactly one * column, with an empty name. See (broken link). */ public final boolean getIsValueTable() { return isValueTable; } public final ResolvedScan getQuery() { return query; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(outputColumnList); visitor.descend(query); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } if (!DebugStrings.isDefaultValue(isValueTable)) { fields.add(new DebugStringField("is_value_table", DebugStrings.toStringImpl(isValueTable))); } if (query != null) { fields.add(new DebugStringField("query", query)); } } } /** * This statement: DEFINE TABLE name (...); * *

is a vector giving the identifier path in the table name. * has engine-specific options of how the table is defined. * *

DEFINE TABLE normally has the same effect as CREATE TEMP EXTERNAL TABLE. */ public static final class ResolvedDefineTableStmt extends ResolvedStatement { private final ImmutableList namePath; private final ImmutableList optionList; protected ResolvedDefineTableStmt(ResolvedDefineTableStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } public static final ResolvedDefineTableStmt deserialize( ResolvedDefineTableStmtProto proto, DeserializationHelper helper) { return new ResolvedDefineTableStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DEFINE_TABLE_STMT; } @Override public final String nodeKindString() { return "DefineTableStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedDefineTableStmtProto.Builder childBuilder = ResolvedDefineTableStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDefineTableStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDefineTableStmtProto.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, ResolvedDefineTableStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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()); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } } public final ImmutableList getNamePath() { return namePath; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This statement: DESCRIBE [] [FROM ]; * *

is an optional string identifier, * e.g., "INDEX", "FUNCTION", "TYPE", etc. * is a vector giving the identifier path for the object to be * described. * is an optional vector giving the identifier path of a * containing object, e.g. a table. */ public static final class ResolvedDescribeStmt extends ResolvedStatement { private final String objectType; private final ImmutableList namePath; private final ImmutableList fromNamePath; protected ResolvedDescribeStmt(ResolvedDescribeStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); objectType = proto.getObjectType(); namePath = ImmutableList.copyOf(proto.getNamePathList()); fromNamePath = ImmutableList.copyOf(proto.getFromNamePathList()); } public static final ResolvedDescribeStmt deserialize( ResolvedDescribeStmtProto proto, DeserializationHelper helper) { return new ResolvedDescribeStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DESCRIBE_STMT; } @Override public final String nodeKindString() { return "DescribeStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedDescribeStmtProto.Builder childBuilder = ResolvedDescribeStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDescribeStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDescribeStmtProto.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, ResolvedDescribeStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // objectType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setObjectType(this.getObjectType()); // 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()); // fromNamePath 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.addAllFromNamePath(this.getFromNamePath()); } public final String getObjectType() { return objectType; } public final ImmutableList getNamePath() { return namePath; } public final ImmutableList getFromNamePath() { return fromNamePath; } @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("object_type", DebugStrings.toStringImpl(objectType))); } { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!DebugStrings.isDefaultValue(fromNamePath)) { fields.add(new DebugStringField("from_name_path", DebugStrings.toStringImpl(fromNamePath))); } } } /** * This statement: SHOW [FROM ] [LIKE ]; * *

is a string that determines the type of objects to be shown, * e.g., TABLES, COLUMNS, INDEXES, STATUS, * is an optional path to an object from which * objects will be shown, e.g., if = INDEXES and * = table_name, the indexes of "table_name" will be * shown, * is an optional ResolvedLiteral of type string that if present * restricts the objects shown to have a name like this string. */ public static final class ResolvedShowStmt extends ResolvedStatement { private final String identifier; private final ImmutableList namePath; private final ResolvedLiteral likeExpr; protected ResolvedShowStmt(ResolvedShowStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); identifier = proto.getIdentifier(); namePath = ImmutableList.copyOf(proto.getNamePathList()); if (proto.hasLikeExpr()) { likeExpr = ResolvedLiteral.deserialize(proto.getLikeExpr(), helper); } else { likeExpr = null; } } public static final ResolvedShowStmt deserialize( ResolvedShowStmtProto proto, DeserializationHelper helper) { return new ResolvedShowStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SHOW_STMT; } @Override public final String nodeKindString() { return "ShowStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedShowStmtProto.Builder childBuilder = ResolvedShowStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedShowStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedShowStmtProto.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, ResolvedShowStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // identifier is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIdentifier(this.getIdentifier()); // 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()); // likeExpr is an AST node. Call its serialization chain. if (this.getLikeExpr() != null) { ResolvedLiteralProto.Builder likeExprBuilder = ResolvedLiteralProto.newBuilder(); this.getLikeExpr().serialize( fileDescriptorSetsBuilder, likeExprBuilder); proto.setLikeExpr( likeExprBuilder.build()); } } public final String getIdentifier() { return identifier; } public final ImmutableList getNamePath() { return namePath; } public final ResolvedLiteral getLikeExpr() { return likeExpr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(likeExpr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("identifier", DebugStrings.toStringImpl(identifier))); } if (!DebugStrings.isDefaultValue(namePath)) { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (likeExpr != null) { fields.add(new DebugStringField("like_expr", likeExpr)); } } } /** * This statement: BEGIN [TRANSACTION] [ [, ...] ] * *

Where transaction_mode is one of: * READ ONLY * READ WRITE * * *

is a string vector storing the identifiers after * ISOLATION LEVEL. The strings inside vector could be one of the * SQL standard isolation levels: * * READ UNCOMMITTED * READ COMMITTED * READ REPEATABLE * SERIALIZABLE * * or could be arbitrary strings. ZetaSQL does not validate that * the string is valid. */ public static final class ResolvedBeginStmt extends ResolvedStatement { private final ReadWriteMode readWriteMode; private final ImmutableList isolationLevelList; protected ResolvedBeginStmt(ResolvedBeginStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); readWriteMode = proto.getReadWriteMode(); isolationLevelList = ImmutableList.copyOf(proto.getIsolationLevelListList()); } public static final ResolvedBeginStmt deserialize( ResolvedBeginStmtProto proto, DeserializationHelper helper) { return new ResolvedBeginStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_BEGIN_STMT; } @Override public final String nodeKindString() { return "BeginStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedBeginStmtProto.Builder childBuilder = ResolvedBeginStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedBeginStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedBeginStmtProto.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, ResolvedBeginStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // readWriteMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setReadWriteMode(this.getReadWriteMode()); // isolationLevelList 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.addAllIsolationLevelList(this.getIsolationLevelList()); } public final ReadWriteMode getReadWriteMode() { return readWriteMode; } public final ImmutableList getIsolationLevelList() { return isolationLevelList; } @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(readWriteMode)) { fields.add(new DebugStringField("read_write_mode", DebugStrings.toStringImpl(readWriteMode))); } if (!DebugStrings.isDefaultValue(isolationLevelList)) { fields.add(new DebugStringField("isolation_level_list", DebugStrings.toStringImpl(isolationLevelList))); } } } /** * This statement: SET TRANSACTION [, ...] * *

Where transaction_mode is one of: * READ ONLY * READ WRITE * * *

is a string vector storing the identifiers after * ISOLATION LEVEL. The strings inside vector could be one of the * SQL standard isolation levels: * * READ UNCOMMITTED * READ COMMITTED * READ REPEATABLE * SERIALIZABLE * * or could be arbitrary strings. ZetaSQL does not validate that * the string is valid. */ public static final class ResolvedSetTransactionStmt extends ResolvedStatement { private final ReadWriteMode readWriteMode; private final ImmutableList isolationLevelList; protected ResolvedSetTransactionStmt(ResolvedSetTransactionStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); readWriteMode = proto.getReadWriteMode(); isolationLevelList = ImmutableList.copyOf(proto.getIsolationLevelListList()); } public static final ResolvedSetTransactionStmt deserialize( ResolvedSetTransactionStmtProto proto, DeserializationHelper helper) { return new ResolvedSetTransactionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SET_TRANSACTION_STMT; } @Override public final String nodeKindString() { return "SetTransactionStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedSetTransactionStmtProto.Builder childBuilder = ResolvedSetTransactionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSetTransactionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSetTransactionStmtProto.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, ResolvedSetTransactionStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // readWriteMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setReadWriteMode(this.getReadWriteMode()); // isolationLevelList 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.addAllIsolationLevelList(this.getIsolationLevelList()); } public final ReadWriteMode getReadWriteMode() { return readWriteMode; } public final ImmutableList getIsolationLevelList() { return isolationLevelList; } @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(readWriteMode)) { fields.add(new DebugStringField("read_write_mode", DebugStrings.toStringImpl(readWriteMode))); } if (!DebugStrings.isDefaultValue(isolationLevelList)) { fields.add(new DebugStringField("isolation_level_list", DebugStrings.toStringImpl(isolationLevelList))); } } } /** * This statement: COMMIT [TRANSACTION]; */ public static final class ResolvedCommitStmt extends ResolvedStatement { protected ResolvedCommitStmt(ResolvedCommitStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedCommitStmt deserialize( ResolvedCommitStmtProto proto, DeserializationHelper helper) { return new ResolvedCommitStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_COMMIT_STMT; } @Override public final String nodeKindString() { return "CommitStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedCommitStmtProto.Builder childBuilder = ResolvedCommitStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCommitStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCommitStmtProto.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, ResolvedCommitStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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); } } /** * This statement: ROLLBACK [TRANSACTION]; */ public static final class ResolvedRollbackStmt extends ResolvedStatement { protected ResolvedRollbackStmt(ResolvedRollbackStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedRollbackStmt deserialize( ResolvedRollbackStmtProto proto, DeserializationHelper helper) { return new ResolvedRollbackStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ROLLBACK_STMT; } @Override public final String nodeKindString() { return "RollbackStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedRollbackStmtProto.Builder childBuilder = ResolvedRollbackStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRollbackStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRollbackStmtProto.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, ResolvedRollbackStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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); } } /** * This statement: START BATCH []; * *

is an optional string identifier that identifies the type of * the batch. (e.g. "DML" or "DDL) */ public static final class ResolvedStartBatchStmt extends ResolvedStatement { private final String batchType; protected ResolvedStartBatchStmt(ResolvedStartBatchStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); batchType = proto.getBatchType(); } public static final ResolvedStartBatchStmt deserialize( ResolvedStartBatchStmtProto proto, DeserializationHelper helper) { return new ResolvedStartBatchStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_START_BATCH_STMT; } @Override public final String nodeKindString() { return "StartBatchStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedStartBatchStmtProto.Builder childBuilder = ResolvedStartBatchStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedStartBatchStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedStartBatchStmtProto.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, ResolvedStartBatchStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // batchType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setBatchType(this.getBatchType()); } public final String getBatchType() { return batchType; } @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(batchType)) { fields.add(new DebugStringField("batch_type", DebugStrings.toStringImpl(batchType))); } } } /** * This statement: RUN BATCH; */ public static final class ResolvedRunBatchStmt extends ResolvedStatement { protected ResolvedRunBatchStmt(ResolvedRunBatchStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedRunBatchStmt deserialize( ResolvedRunBatchStmtProto proto, DeserializationHelper helper) { return new ResolvedRunBatchStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RUN_BATCH_STMT; } @Override public final String nodeKindString() { return "RunBatchStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedRunBatchStmtProto.Builder childBuilder = ResolvedRunBatchStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRunBatchStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRunBatchStmtProto.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, ResolvedRunBatchStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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); } } /** * This statement: ABORT BATCH; */ public static final class ResolvedAbortBatchStmt extends ResolvedStatement { protected ResolvedAbortBatchStmt(ResolvedAbortBatchStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedAbortBatchStmt deserialize( ResolvedAbortBatchStmtProto proto, DeserializationHelper helper) { return new ResolvedAbortBatchStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ABORT_BATCH_STMT; } @Override public final String nodeKindString() { return "AbortBatchStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedAbortBatchStmtProto.Builder childBuilder = ResolvedAbortBatchStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAbortBatchStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAbortBatchStmtProto.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, ResolvedAbortBatchStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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); } } /** * This statement: DROP [IF EXISTS] ; * *

is an string identifier, * e.g., "TABLE", "VIEW", "INDEX", "FUNCTION", "TYPE", etc. * is a vector giving the identifier path for the object to be * dropped. * silently ignore the "name_path does not exist" error. */ public static final class ResolvedDropStmt extends ResolvedStatement { private final String objectType; private final boolean isIfExists; private final ImmutableList namePath; protected ResolvedDropStmt(ResolvedDropStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); objectType = proto.getObjectType(); isIfExists = proto.getIsIfExists(); namePath = ImmutableList.copyOf(proto.getNamePathList()); } public static final ResolvedDropStmt deserialize( ResolvedDropStmtProto proto, DeserializationHelper helper) { return new ResolvedDropStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_STMT; } @Override public final String nodeKindString() { return "DropStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedDropStmtProto.Builder childBuilder = ResolvedDropStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropStmtProto.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, ResolvedDropStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // objectType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setObjectType(this.getObjectType()); // isIfExists is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsIfExists(this.getIsIfExists()); // 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()); } public final String getObjectType() { return objectType; } public final boolean getIsIfExists() { return isIfExists; } 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); { fields.add(new DebugStringField("object_type", DebugStrings.toStringImpl(objectType))); } { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } } } /** * This statement: DROP MATERIALIZED VIEW [IF EXISTS] ; * *

is a vector giving the identifier path for the object to be * dropped. * silently ignore the "name_path does not exist" error. */ public static final class ResolvedDropMaterializedViewStmt extends ResolvedStatement { private final boolean isIfExists; private final ImmutableList namePath; protected ResolvedDropMaterializedViewStmt(ResolvedDropMaterializedViewStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); namePath = ImmutableList.copyOf(proto.getNamePathList()); } public static final ResolvedDropMaterializedViewStmt deserialize( ResolvedDropMaterializedViewStmtProto proto, DeserializationHelper helper) { return new ResolvedDropMaterializedViewStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_MATERIALIZED_VIEW_STMT; } @Override public final String nodeKindString() { return "DropMaterializedViewStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedDropMaterializedViewStmtProto.Builder childBuilder = ResolvedDropMaterializedViewStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropMaterializedViewStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropMaterializedViewStmtProto.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, ResolvedDropMaterializedViewStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // isIfExists is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsIfExists(this.getIsIfExists()); // 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()); } public final boolean getIsIfExists() { return isIfExists; } 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); { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } } } /** * This represents a SQL WITH query (or subquery) like * WITH AS (), * AS () * ; * *

A may be referenced (multiple times) inside a later * with_subquery, or in the final . * *

If a WITH subquery is referenced multiple times, the full query should * behave as if the subquery runs only once and its result is reused. * *

There will be one ResolvedWithEntry here for each subquery in the SQL * WITH statement, in the same order as in the query. * *

Inside the resolved , or any occurring after * its definition, a used as a table scan will be * represented using a ResolvedWithRefScan. * *

The aliases are always unique within a query, and should * be used to connect the ResolvedWithRefScan to the original query * definition. The subqueries are not inlined and duplicated into the tree. * *

In ZetaSQL 1.0, WITH is allowed only on the outermost query and not in * subqueries, so the ResolvedWithScan node can only occur as the outermost * scan in a statement (e.g. a QueryStmt or CreateTableAsSelectStmt). * *

In ZetaSQL 1.1 (language option FEATURE_V_1_1_WITH_ON_SUBQUERY), WITH * is allowed on subqueries. Then, ResolvedWithScan can occur anywhere in * the tree. The alias introduced by a ResolvedWithEntry is visible only * in subsequent ResolvedWithEntry queries and in . The aliases used * must be globally unique in the resolved AST however, so consumers do not * need to implement any scoping for these names. Because the aliases are * unique, it is legal to collect all ResolvedWithEntries in the tree and * treat them as if they were a single WITH clause at the outermost level. * *

The subqueries inside ResolvedWithEntries cannot be correlated. * *

If a WITH subquery is defined but never referenced, it will still be * resolved and still show up here. Query engines may choose not to run it. * *

SQL-style WITH RECURSIVE is not currently supported. */ public static final class ResolvedWithScan extends ResolvedScan { private final ImmutableList withEntryList; private final ResolvedScan query; protected ResolvedWithScan(ResolvedWithScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder withEntryListBuilder = ImmutableList.builder(); for (ResolvedWithEntryProto element : proto.getWithEntryListList()) { withEntryListBuilder .add(ResolvedWithEntry.deserialize(element, helper)); } withEntryList = withEntryListBuilder.build(); if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } } public static final ResolvedWithScan deserialize( ResolvedWithScanProto proto, DeserializationHelper helper) { return new ResolvedWithScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_WITH_SCAN; } @Override public final String nodeKindString() { return "WithScan"; } /** * 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(); ResolvedWithScanProto.Builder childBuilder = ResolvedWithScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedWithScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedWithScanProto.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, ResolvedWithScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // withEntryList is a collection of AST nodes. Serialize each of them. ImmutableList withEntryLists = this.getWithEntryList(); for (ResolvedWithEntry element : withEntryLists) { ResolvedWithEntryProto.Builder withEntryListBuilder = ResolvedWithEntryProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, withEntryListBuilder); proto.addWithEntryList(withEntryListBuilder.build()); } // query is an AST node. Call its serialization chain. if (this.getQuery() != null) { AnyResolvedScanProto.Builder queryBuilder = AnyResolvedScanProto.newBuilder(); this.getQuery().serialize( fileDescriptorSetsBuilder, queryBuilder); proto.setQuery( queryBuilder.build()); } } public final ImmutableList getWithEntryList() { return withEntryList; } public final ResolvedScan getQuery() { return query; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(withEntryList); visitor.descend(query); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!withEntryList.isEmpty()) { fields.add(new DebugStringField("with_entry_list", withEntryList)); } if (query != null) { fields.add(new DebugStringField("query", query)); } } } /** * This represents one aliased subquery introduced in a WITH clause. * *

The s must be globally unique in the full resolved AST. * The cannot be correlated and cannot reference any * columns from outside. It may reference other WITH subqueries. * *

See ResolvedWithScan for full details. */ public static final class ResolvedWithEntry extends ResolvedArgument { private final String withQueryName; private final ResolvedScan withSubquery; protected ResolvedWithEntry(ResolvedWithEntryProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); withQueryName = proto.getWithQueryName(); if (proto.hasWithSubquery()) { withSubquery = ResolvedScan.deserialize(proto.getWithSubquery(), helper); } else { withSubquery = null; } } public static final ResolvedWithEntry deserialize( ResolvedWithEntryProto proto, DeserializationHelper helper) { return new ResolvedWithEntry(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_WITH_ENTRY; } @Override public final String nodeKindString() { return "WithEntry"; } /** * 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(); ResolvedWithEntryProto.Builder childBuilder = ResolvedWithEntryProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedWithEntryNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedWithEntryProto.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, ResolvedWithEntryProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // withQueryName is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setWithQueryName(this.getWithQueryName()); // withSubquery is an AST node. Call its serialization chain. if (this.getWithSubquery() != null) { AnyResolvedScanProto.Builder withSubqueryBuilder = AnyResolvedScanProto.newBuilder(); this.getWithSubquery().serialize( fileDescriptorSetsBuilder, withSubqueryBuilder); proto.setWithSubquery( withSubqueryBuilder.build()); } } public final String getWithQueryName() { return withQueryName; } public final ResolvedScan getWithSubquery() { return withSubquery; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(withSubquery); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("with_query_name", DebugStrings.toStringImpl(withQueryName))); } if (withSubquery != null) { fields.add(new DebugStringField("with_subquery", withSubquery)); } } } /** * This represents one SQL hint key/value pair. * The SQL syntax @{ key1=value1, key2=value2, some_db.key3=value3 } * will expand to three ResolvedOptions. Keyword hints (e.g. LOOKUP JOIN) * are interpreted as shorthand, and will be expanded to a ResolvedOption * attached to the appropriate node before any explicit long-form hints. * *

ResolvedOptions are attached to the ResolvedScan corresponding to the * operator that the SQL hint was associated with. * See (broken link) for more detail. * Hint semantics are implementation defined. * *

Each hint is resolved as a [.]:= pair. * will be empty if no qualifier was present. * is always non-empty. * can be a ResolvedLiteral or a ResolvedParameter, * a cast of a ResolvedParameter (for typed hints only), * or a general expression (on constant inputs). * *

If AllowedHintsAndOptions was set in AnalyzerOptions, and this hint or * option was included there and had an expected type, the type of * will match that expected type. Unknown hints (not listed in * AllowedHintsAndOptions) are not stripped and will still show up here. * *

If non-empty, should be interpreted as a target system name, * and a database system should ignore any hints targeted to different * systems. * *

The SQL syntax allows using an identifier as a hint value. * Such values are stored here as ResolvedLiterals with string type. */ public static final class ResolvedOption extends ResolvedArgument { private final String qualifier; private final String name; private final ResolvedExpr value; protected ResolvedOption(ResolvedOptionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); qualifier = proto.getQualifier(); name = proto.getName(); if (proto.hasValue()) { value = ResolvedExpr.deserialize(proto.getValue(), helper); } else { value = null; } } public static final ResolvedOption deserialize( ResolvedOptionProto proto, DeserializationHelper helper) { return new ResolvedOption(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_OPTION; } @Override public final String nodeKindString() { return "Option"; } /** * 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(); ResolvedOptionProto.Builder childBuilder = ResolvedOptionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedOptionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedOptionProto.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, ResolvedOptionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // qualifier is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setQualifier(this.getQualifier()); // 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()); // value is an AST node. Call its serialization chain. if (this.getValue() != null) { AnyResolvedExprProto.Builder valueBuilder = AnyResolvedExprProto.newBuilder(); this.getValue().serialize( fileDescriptorSetsBuilder, valueBuilder); proto.setValue( valueBuilder.build()); } } public final String getQualifier() { return qualifier; } public final String getName() { return name; } public final ResolvedExpr getValue() { return value; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(value); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } protected String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * Window partitioning specification for an analytic function call. * *

PARTITION BY keys in . */ public static final class ResolvedWindowPartitioning extends ResolvedArgument { private final ImmutableList partitionByList; private final ImmutableList hintList; protected ResolvedWindowPartitioning(ResolvedWindowPartitioningProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder partitionByListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getPartitionByListList()) { partitionByListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } partitionByList = partitionByListBuilder.build(); ImmutableList.Builder hintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getHintListList()) { hintListBuilder .add(ResolvedOption.deserialize(element, helper)); } hintList = hintListBuilder.build(); } public static final ResolvedWindowPartitioning deserialize( ResolvedWindowPartitioningProto proto, DeserializationHelper helper) { return new ResolvedWindowPartitioning(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_WINDOW_PARTITIONING; } @Override public final String nodeKindString() { return "WindowPartitioning"; } /** * 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(); ResolvedWindowPartitioningProto.Builder childBuilder = ResolvedWindowPartitioningProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedWindowPartitioningNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedWindowPartitioningProto.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, ResolvedWindowPartitioningProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // partitionByList is a collection of AST nodes. Serialize each of them. ImmutableList partitionByLists = this.getPartitionByList(); for (ResolvedColumnRef element : partitionByLists) { ResolvedColumnRefProto.Builder partitionByListBuilder = ResolvedColumnRefProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, partitionByListBuilder); proto.addPartitionByList(partitionByListBuilder.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 ImmutableList getPartitionByList() { return partitionByList; } 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(partitionByList); visitor.descend(hintList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!partitionByList.isEmpty()) { fields.add(new DebugStringField("partition_by_list", partitionByList)); } if (!hintList.isEmpty()) { fields.add(new DebugStringField("hint_list", hintList)); } } } /** * Window ordering specification for an analytic function call. * *

ORDER BY items in . There should be exactly one ORDER * BY item if this is a window ORDER BY for a RANGE-based window. */ public static final class ResolvedWindowOrdering extends ResolvedArgument { private final ImmutableList orderByItemList; private final ImmutableList hintList; protected ResolvedWindowOrdering(ResolvedWindowOrderingProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder orderByItemListBuilder = ImmutableList.builder(); for (ResolvedOrderByItemProto element : proto.getOrderByItemListList()) { orderByItemListBuilder .add(ResolvedOrderByItem.deserialize(element, helper)); } orderByItemList = orderByItemListBuilder.build(); ImmutableList.Builder hintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getHintListList()) { hintListBuilder .add(ResolvedOption.deserialize(element, helper)); } hintList = hintListBuilder.build(); } public static final ResolvedWindowOrdering deserialize( ResolvedWindowOrderingProto proto, DeserializationHelper helper) { return new ResolvedWindowOrdering(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_WINDOW_ORDERING; } @Override public final String nodeKindString() { return "WindowOrdering"; } /** * 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(); ResolvedWindowOrderingProto.Builder childBuilder = ResolvedWindowOrderingProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedWindowOrderingNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedWindowOrderingProto.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, ResolvedWindowOrderingProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // 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()); } // 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 ImmutableList getOrderByItemList() { return orderByItemList; } 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(orderByItemList); visitor.descend(hintList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!orderByItemList.isEmpty()) { fields.add(new DebugStringField("order_by_item_list", orderByItemList)); } if (!hintList.isEmpty()) { fields.add(new DebugStringField("hint_list", hintList)); } } } /** * Window framing specification for an analytic function call. * *

ROW-based window frames compute the frame based on physical offsets * from the current row. * RANGE-based window frames compute the frame based on a logical * range of rows around the current row based on the current row's * ORDER BY key value. * *

and cannot be NULL. If the window frame * is one-sided in the input query, the resolver will generate an * implicit ending boundary. */ public static final class ResolvedWindowFrame extends ResolvedArgument { private final FrameUnit frameUnit; private final ResolvedWindowFrameExpr startExpr; private final ResolvedWindowFrameExpr endExpr; protected ResolvedWindowFrame(ResolvedWindowFrameProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); frameUnit = proto.getFrameUnit(); if (proto.hasStartExpr()) { startExpr = ResolvedWindowFrameExpr.deserialize(proto.getStartExpr(), helper); } else { startExpr = null; } if (proto.hasEndExpr()) { endExpr = ResolvedWindowFrameExpr.deserialize(proto.getEndExpr(), helper); } else { endExpr = null; } } public static final ResolvedWindowFrame deserialize( ResolvedWindowFrameProto proto, DeserializationHelper helper) { return new ResolvedWindowFrame(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_WINDOW_FRAME; } @Override public final String nodeKindString() { return "WindowFrame"; } /** * 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(); ResolvedWindowFrameProto.Builder childBuilder = ResolvedWindowFrameProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedWindowFrameNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedWindowFrameProto.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, ResolvedWindowFrameProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // frameUnit is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setFrameUnit(this.getFrameUnit()); // startExpr is an AST node. Call its serialization chain. if (this.getStartExpr() != null) { ResolvedWindowFrameExprProto.Builder startExprBuilder = ResolvedWindowFrameExprProto.newBuilder(); this.getStartExpr().serialize( fileDescriptorSetsBuilder, startExprBuilder); proto.setStartExpr( startExprBuilder.build()); } // endExpr is an AST node. Call its serialization chain. if (this.getEndExpr() != null) { ResolvedWindowFrameExprProto.Builder endExprBuilder = ResolvedWindowFrameExprProto.newBuilder(); this.getEndExpr().serialize( fileDescriptorSetsBuilder, endExprBuilder); proto.setEndExpr( endExprBuilder.build()); } } public final FrameUnit getFrameUnit() { return frameUnit; } public final ResolvedWindowFrameExpr getStartExpr() { return startExpr; } public final ResolvedWindowFrameExpr getEndExpr() { return endExpr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(startExpr); visitor.descend(endExpr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } protected String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * This represents a group of analytic function calls that shares PARTITION * BY and ORDER BY. * *

can be NULL. may be NULL depending on the * functions in and the window frame unit. See * (broken link) for more details. * *

All expressions in have a * ResolvedAggregateFunctionCall with a function in mode * Function::AGGREGATE or Function::ANALYTIC. */ public static final class ResolvedAnalyticFunctionGroup extends ResolvedArgument { private final ResolvedWindowPartitioning partitionBy; private final ResolvedWindowOrdering orderBy; private final ImmutableList analyticFunctionList; protected ResolvedAnalyticFunctionGroup(ResolvedAnalyticFunctionGroupProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasPartitionBy()) { partitionBy = ResolvedWindowPartitioning.deserialize(proto.getPartitionBy(), helper); } else { partitionBy = null; } if (proto.hasOrderBy()) { orderBy = ResolvedWindowOrdering.deserialize(proto.getOrderBy(), helper); } else { orderBy = null; } ImmutableList.Builder analyticFunctionListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getAnalyticFunctionListList()) { analyticFunctionListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } analyticFunctionList = analyticFunctionListBuilder.build(); } public static final ResolvedAnalyticFunctionGroup deserialize( ResolvedAnalyticFunctionGroupProto proto, DeserializationHelper helper) { return new ResolvedAnalyticFunctionGroup(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ANALYTIC_FUNCTION_GROUP; } @Override public final String nodeKindString() { return "AnalyticFunctionGroup"; } /** * 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(); ResolvedAnalyticFunctionGroupProto.Builder childBuilder = ResolvedAnalyticFunctionGroupProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAnalyticFunctionGroupNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAnalyticFunctionGroupProto.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, ResolvedAnalyticFunctionGroupProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // partitionBy is an AST node. Call its serialization chain. if (this.getPartitionBy() != null) { ResolvedWindowPartitioningProto.Builder partitionByBuilder = ResolvedWindowPartitioningProto.newBuilder(); this.getPartitionBy().serialize( fileDescriptorSetsBuilder, partitionByBuilder); proto.setPartitionBy( partitionByBuilder.build()); } // orderBy is an AST node. Call its serialization chain. if (this.getOrderBy() != null) { ResolvedWindowOrderingProto.Builder orderByBuilder = ResolvedWindowOrderingProto.newBuilder(); this.getOrderBy().serialize( fileDescriptorSetsBuilder, orderByBuilder); proto.setOrderBy( orderByBuilder.build()); } // analyticFunctionList is a collection of AST nodes. Serialize each of them. ImmutableList analyticFunctionLists = this.getAnalyticFunctionList(); for (ResolvedComputedColumn element : analyticFunctionLists) { ResolvedComputedColumnProto.Builder analyticFunctionListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, analyticFunctionListBuilder); proto.addAnalyticFunctionList(analyticFunctionListBuilder.build()); } } public final ResolvedWindowPartitioning getPartitionBy() { return partitionBy; } public final ResolvedWindowOrdering getOrderBy() { return orderBy; } public final ImmutableList getAnalyticFunctionList() { return analyticFunctionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(partitionBy); visitor.descend(orderBy); visitor.descend(analyticFunctionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (partitionBy != null) { fields.add(new DebugStringField("partition_by", partitionBy)); } if (orderBy != null) { fields.add(new DebugStringField("order_by", orderBy)); } if (!analyticFunctionList.isEmpty()) { fields.add(new DebugStringField("analytic_function_list", analyticFunctionList)); } } } /** * Window frame boundary expression that determines the first/last row of * the moving window for each tuple. * *

cannot be NULL if the type is OFFSET_PRECEDING * or OFFSET_FOLLOWING. It must be a constant expression. If this is a * boundary for a ROW-based window, it must be integer type. Otherwise, * it must be numeric type and must match exactly the type of the window * ordering expression. See (broken link) for more * details. */ public static final class ResolvedWindowFrameExpr extends ResolvedArgument { private final BoundaryType boundaryType; private final ResolvedExpr expression; protected ResolvedWindowFrameExpr(ResolvedWindowFrameExprProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); boundaryType = proto.getBoundaryType(); if (proto.hasExpression()) { expression = ResolvedExpr.deserialize(proto.getExpression(), helper); } else { expression = null; } } public static final ResolvedWindowFrameExpr deserialize( ResolvedWindowFrameExprProto proto, DeserializationHelper helper) { return new ResolvedWindowFrameExpr(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_WINDOW_FRAME_EXPR; } @Override public final String nodeKindString() { return "WindowFrameExpr"; } /** * 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(); ResolvedWindowFrameExprProto.Builder childBuilder = ResolvedWindowFrameExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedWindowFrameExprNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedWindowFrameExprProto.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, ResolvedWindowFrameExprProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // boundaryType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setBoundaryType(this.getBoundaryType()); // expression is an AST node. Call its serialization chain. if (this.getExpression() != null) { AnyResolvedExprProto.Builder expressionBuilder = AnyResolvedExprProto.newBuilder(); this.getExpression().serialize( fileDescriptorSetsBuilder, expressionBuilder); proto.setExpression( expressionBuilder.build()); } } public final BoundaryType getBoundaryType() { return boundaryType; } public final ResolvedExpr getExpression() { return expression; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } protected String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * This represents a value inside an INSERT or UPDATE statement. * *

The is either an expression or a DMLDefault. * *

For proto fields, NULL values mean the field should be cleared. */ public static final class ResolvedDMLValue extends ResolvedArgument { private final ResolvedExpr value; protected ResolvedDMLValue(ResolvedDMLValueProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasValue()) { value = ResolvedExpr.deserialize(proto.getValue(), helper); } else { value = null; } } public static final ResolvedDMLValue deserialize( ResolvedDMLValueProto proto, DeserializationHelper helper) { return new ResolvedDMLValue(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DMLVALUE; } @Override public final String nodeKindString() { return "DMLValue"; } /** * 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(); ResolvedDMLValueProto.Builder childBuilder = ResolvedDMLValueProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDmlvalueNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDMLValueProto.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, ResolvedDMLValueProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // value is an AST node. Call its serialization chain. if (this.getValue() != null) { AnyResolvedExprProto.Builder valueBuilder = AnyResolvedExprProto.newBuilder(); this.getValue().serialize( fileDescriptorSetsBuilder, valueBuilder); proto.setValue( valueBuilder.build()); } } public final ResolvedExpr getValue() { return value; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(value); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (value != null) { fields.add(new DebugStringField("value", value)); } } } /** * This is used to represent the value DEFAULT that shows up (in place of a * value expression) in INSERT and UPDATE statements. * For columns, engines should substitute the engine-defined default value * for that column, or give an error. * For proto fields, this always means to clear the field. * This will never show up inside expressions other than ResolvedDMLValue. */ public static final class ResolvedDMLDefault extends ResolvedExpr { protected ResolvedDMLDefault(ResolvedDMLDefaultProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedDMLDefault deserialize( ResolvedDMLDefaultProto proto, DeserializationHelper helper) { return new ResolvedDMLDefault(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DMLDEFAULT; } @Override public final String nodeKindString() { return "DMLDefault"; } /** * 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(); ResolvedDMLDefaultProto.Builder childBuilder = ResolvedDMLDefaultProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDmldefaultNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDMLDefaultProto.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, ResolvedDMLDefaultProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) 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); } } /** * This represents the ASSERT statement: * ASSERT [AS ]; * *

is any expression that returns a bool. * is an optional string literal used to give a more * descriptive error message in case the ASSERT fails. */ public static final class ResolvedAssertStmt extends ResolvedStatement { private final ResolvedExpr expression; private final String description; protected ResolvedAssertStmt(ResolvedAssertStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpression()) { expression = ResolvedExpr.deserialize(proto.getExpression(), helper); } else { expression = null; } description = proto.getDescription(); } public static final ResolvedAssertStmt deserialize( ResolvedAssertStmtProto proto, DeserializationHelper helper) { return new ResolvedAssertStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ASSERT_STMT; } @Override public final String nodeKindString() { return "AssertStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedAssertStmtProto.Builder childBuilder = ResolvedAssertStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAssertStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAssertStmtProto.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, ResolvedAssertStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // expression is an AST node. Call its serialization chain. if (this.getExpression() != null) { AnyResolvedExprProto.Builder expressionBuilder = AnyResolvedExprProto.newBuilder(); this.getExpression().serialize( fileDescriptorSetsBuilder, expressionBuilder); proto.setExpression( expressionBuilder.build()); } // description is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setDescription(this.getDescription()); } public final ResolvedExpr getExpression() { return expression; } public final String getDescription() { return description; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expression != null) { fields.add(new DebugStringField("expression", expression)); } if (!DebugStrings.isDefaultValue(description)) { fields.add(new DebugStringField("description", DebugStrings.toStringImpl(description))); } } } /** * This represents the ASSERT ROWS MODIFIED clause on a DML statement. * The value must be a literal or (possibly casted) parameter int64. * *

The statement should fail if the number of rows updated does not * exactly match this number. */ public static final class ResolvedAssertRowsModified extends ResolvedArgument { private final ResolvedExpr rows; protected ResolvedAssertRowsModified(ResolvedAssertRowsModifiedProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasRows()) { rows = ResolvedExpr.deserialize(proto.getRows(), helper); } else { rows = null; } } public static final ResolvedAssertRowsModified deserialize( ResolvedAssertRowsModifiedProto proto, DeserializationHelper helper) { return new ResolvedAssertRowsModified(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ASSERT_ROWS_MODIFIED; } @Override public final String nodeKindString() { return "AssertRowsModified"; } /** * 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(); ResolvedAssertRowsModifiedProto.Builder childBuilder = ResolvedAssertRowsModifiedProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAssertRowsModifiedNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAssertRowsModifiedProto.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, ResolvedAssertRowsModifiedProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // rows is an AST node. Call its serialization chain. if (this.getRows() != null) { AnyResolvedExprProto.Builder rowsBuilder = AnyResolvedExprProto.newBuilder(); this.getRows().serialize( fileDescriptorSetsBuilder, rowsBuilder); proto.setRows( rowsBuilder.build()); } } public final ResolvedExpr getRows() { return rows; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(rows); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (rows != null) { fields.add(new DebugStringField("rows", rows)); } } } /** * This represents one row in the VALUES clause of an INSERT. */ public static final class ResolvedInsertRow extends ResolvedArgument { private final ImmutableList valueList; protected ResolvedInsertRow(ResolvedInsertRowProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder valueListBuilder = ImmutableList.builder(); for (ResolvedDMLValueProto element : proto.getValueListList()) { valueListBuilder .add(ResolvedDMLValue.deserialize(element, helper)); } valueList = valueListBuilder.build(); } public static final ResolvedInsertRow deserialize( ResolvedInsertRowProto proto, DeserializationHelper helper) { return new ResolvedInsertRow(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_INSERT_ROW; } @Override public final String nodeKindString() { return "InsertRow"; } /** * 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(); ResolvedInsertRowProto.Builder childBuilder = ResolvedInsertRowProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedInsertRowNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedInsertRowProto.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, ResolvedInsertRowProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // valueList is a collection of AST nodes. Serialize each of them. ImmutableList valueLists = this.getValueList(); for (ResolvedDMLValue element : valueLists) { ResolvedDMLValueProto.Builder valueListBuilder = ResolvedDMLValueProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, valueListBuilder); proto.addValueList(valueListBuilder.build()); } } public final ImmutableList getValueList() { return valueList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(valueList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!valueList.isEmpty()) { fields.add(new DebugStringField("value_list", valueList)); } } } /** * This represents an INSERT statement, or a nested INSERT inside an * UPDATE statement. * *

For top-level INSERT statements, gives the table to * scan and creates ResolvedColumns for its columns. Those columns can be * referenced in . * *

For nested INSERTS, there is no or . * There is implicitly a single column to insert, and its type is the * element type of the array being updated in the ResolvedUpdateItem * containing this statement. * *

For nested INSERTs, alternate modes are not supported and * will always be set to OR_ERROR. * *

The rows to insert come from or the result of . * Exactly one of these must be present. * *

If is present, the columns in the row_list match * positionally with . * *

If is present, must also be present. * is the list of output columns produced by * that correspond positionally with the target * on the output table. For nested INSERTs with no , * must have exactly one column. * *

is set for nested INSERTs where is set and * references non-target values (columns or field values) from the table. It * is only set when FEATURE_V_1_2_CORRELATED_REFS_IN_NESTED_DML is enabled. */ public static final class ResolvedInsertStmt extends ResolvedStatement { private final ResolvedTableScan tableScan; /** * Behavior on duplicate rows (normally defined to mean duplicate * primary keys). */ private final InsertMode insertMode; private final ResolvedAssertRowsModified assertRowsModified; private final ImmutableList insertColumnList; private final ImmutableList queryParameterList; private final ResolvedScan query; private final ImmutableList queryOutputColumnList; private final ImmutableList rowList; protected ResolvedInsertStmt(ResolvedInsertStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } insertMode = proto.getInsertMode(); if (proto.hasAssertRowsModified()) { assertRowsModified = ResolvedAssertRowsModified.deserialize(proto.getAssertRowsModified(), helper); } else { assertRowsModified = null; } ImmutableList.Builder insertColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getInsertColumnListList()) { insertColumnListBuilder.add(helper.deserialize(element)); } insertColumnList = insertColumnListBuilder.build(); ImmutableList.Builder queryParameterListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getQueryParameterListList()) { queryParameterListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } queryParameterList = queryParameterListBuilder.build(); if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } ImmutableList.Builder queryOutputColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getQueryOutputColumnListList()) { queryOutputColumnListBuilder.add(helper.deserialize(element)); } queryOutputColumnList = queryOutputColumnListBuilder.build(); ImmutableList.Builder rowListBuilder = ImmutableList.builder(); for (ResolvedInsertRowProto element : proto.getRowListList()) { rowListBuilder .add(ResolvedInsertRow.deserialize(element, helper)); } rowList = rowListBuilder.build(); } public static final ResolvedInsertStmt deserialize( ResolvedInsertStmtProto proto, DeserializationHelper helper) { return new ResolvedInsertStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_INSERT_STMT; } @Override public final String nodeKindString() { return "InsertStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedInsertStmtProto.Builder childBuilder = ResolvedInsertStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedInsertStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedInsertStmtProto.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, ResolvedInsertStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // tableScan is an AST node. Call its serialization chain. if (this.getTableScan() != null) { ResolvedTableScanProto.Builder tableScanBuilder = ResolvedTableScanProto.newBuilder(); this.getTableScan().serialize( fileDescriptorSetsBuilder, tableScanBuilder); proto.setTableScan( tableScanBuilder.build()); } // insertMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setInsertMode(this.getInsertMode()); // assertRowsModified is an AST node. Call its serialization chain. if (this.getAssertRowsModified() != null) { ResolvedAssertRowsModifiedProto.Builder assertRowsModifiedBuilder = ResolvedAssertRowsModifiedProto.newBuilder(); this.getAssertRowsModified().serialize( fileDescriptorSetsBuilder, assertRowsModifiedBuilder); proto.setAssertRowsModified( assertRowsModifiedBuilder.build()); } // insertColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList insertColumnLists = this.getInsertColumnList(); for (ResolvedColumn element : insertColumnLists) { proto.addInsertColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // queryParameterList is a collection of AST nodes. Serialize each of them. ImmutableList queryParameterLists = this.getQueryParameterList(); for (ResolvedColumnRef element : queryParameterLists) { ResolvedColumnRefProto.Builder queryParameterListBuilder = ResolvedColumnRefProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, queryParameterListBuilder); proto.addQueryParameterList(queryParameterListBuilder.build()); } // query is an AST node. Call its serialization chain. if (this.getQuery() != null) { AnyResolvedScanProto.Builder queryBuilder = AnyResolvedScanProto.newBuilder(); this.getQuery().serialize( fileDescriptorSetsBuilder, queryBuilder); proto.setQuery( queryBuilder.build()); } // queryOutputColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList queryOutputColumnLists = this.getQueryOutputColumnList(); for (ResolvedColumn element : queryOutputColumnLists) { proto.addQueryOutputColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // rowList is a collection of AST nodes. Serialize each of them. ImmutableList rowLists = this.getRowList(); for (ResolvedInsertRow element : rowLists) { ResolvedInsertRowProto.Builder rowListBuilder = ResolvedInsertRowProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, rowListBuilder); proto.addRowList(rowListBuilder.build()); } } public final ResolvedTableScan getTableScan() { return tableScan; } /** * Behavior on duplicate rows (normally defined to mean duplicate * primary keys). */ public final InsertMode getInsertMode() { return insertMode; } public final ResolvedAssertRowsModified getAssertRowsModified() { return assertRowsModified; } public final ImmutableList getInsertColumnList() { return insertColumnList; } public final ImmutableList getQueryParameterList() { return queryParameterList; } public final ResolvedScan getQuery() { return query; } public final ImmutableList getQueryOutputColumnList() { return queryOutputColumnList; } public final ImmutableList getRowList() { return rowList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(assertRowsModified); visitor.descend(queryParameterList); visitor.descend(query); visitor.descend(rowList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (tableScan != null) { fields.add(new DebugStringField("table_scan", tableScan)); } if (!DebugStrings.isDefaultValue(insertMode)) { fields.add(new DebugStringField("insert_mode", DebugStrings.toStringImpl(insertMode))); } if (assertRowsModified != null) { fields.add(new DebugStringField("assert_rows_modified", assertRowsModified)); } if (!DebugStrings.isDefaultValue(insertColumnList)) { fields.add(new DebugStringField("insert_column_list", DebugStrings.toStringImpl(insertColumnList))); } if (!queryParameterList.isEmpty()) { fields.add(new DebugStringField("query_parameter_list", queryParameterList)); } if (query != null) { fields.add(new DebugStringField("query", query)); } if (!DebugStrings.isDefaultValue(queryOutputColumnList)) { fields.add(new DebugStringField("query_output_column_list", DebugStrings.toStringImpl(queryOutputColumnList))); } if (!rowList.isEmpty()) { fields.add(new DebugStringField("row_list", rowList)); } } } /** * This represents a DELETE statement or a nested DELETE inside an * UPDATE statement. * *

For top-level DELETE statements, gives the table to * scan and creates ResolvedColumns for its columns. Those columns can * be referenced inside the . * *

For nested DELETEs, there is no . The can * only reference: * (1) the element_column from the ResolvedUpdateItem containing this * statement, * (2) columns from the outer statements, and * (3) (optionally) , which represents the 0-based * offset of the array element being modified. * *

is required. */ public static final class ResolvedDeleteStmt extends ResolvedStatement { private final ResolvedTableScan tableScan; private final ResolvedAssertRowsModified assertRowsModified; private final ResolvedColumnHolder arrayOffsetColumn; private final ResolvedExpr whereExpr; protected ResolvedDeleteStmt(ResolvedDeleteStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } if (proto.hasAssertRowsModified()) { assertRowsModified = ResolvedAssertRowsModified.deserialize(proto.getAssertRowsModified(), helper); } else { assertRowsModified = null; } if (proto.hasArrayOffsetColumn()) { arrayOffsetColumn = ResolvedColumnHolder.deserialize(proto.getArrayOffsetColumn(), helper); } else { arrayOffsetColumn = null; } if (proto.hasWhereExpr()) { whereExpr = ResolvedExpr.deserialize(proto.getWhereExpr(), helper); } else { whereExpr = null; } } public static final ResolvedDeleteStmt deserialize( ResolvedDeleteStmtProto proto, DeserializationHelper helper) { return new ResolvedDeleteStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DELETE_STMT; } @Override public final String nodeKindString() { return "DeleteStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedDeleteStmtProto.Builder childBuilder = ResolvedDeleteStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDeleteStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDeleteStmtProto.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, ResolvedDeleteStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // tableScan is an AST node. Call its serialization chain. if (this.getTableScan() != null) { ResolvedTableScanProto.Builder tableScanBuilder = ResolvedTableScanProto.newBuilder(); this.getTableScan().serialize( fileDescriptorSetsBuilder, tableScanBuilder); proto.setTableScan( tableScanBuilder.build()); } // assertRowsModified is an AST node. Call its serialization chain. if (this.getAssertRowsModified() != null) { ResolvedAssertRowsModifiedProto.Builder assertRowsModifiedBuilder = ResolvedAssertRowsModifiedProto.newBuilder(); this.getAssertRowsModified().serialize( fileDescriptorSetsBuilder, assertRowsModifiedBuilder); proto.setAssertRowsModified( assertRowsModifiedBuilder.build()); } // arrayOffsetColumn is an AST node. Call its serialization chain. if (this.getArrayOffsetColumn() != null) { ResolvedColumnHolderProto.Builder arrayOffsetColumnBuilder = ResolvedColumnHolderProto.newBuilder(); this.getArrayOffsetColumn().serialize( fileDescriptorSetsBuilder, arrayOffsetColumnBuilder); proto.setArrayOffsetColumn( arrayOffsetColumnBuilder.build()); } // whereExpr is an AST node. Call its serialization chain. if (this.getWhereExpr() != null) { AnyResolvedExprProto.Builder whereExprBuilder = AnyResolvedExprProto.newBuilder(); this.getWhereExpr().serialize( fileDescriptorSetsBuilder, whereExprBuilder); proto.setWhereExpr( whereExprBuilder.build()); } } public final ResolvedTableScan getTableScan() { return tableScan; } public final ResolvedAssertRowsModified getAssertRowsModified() { return assertRowsModified; } public final ResolvedColumnHolder getArrayOffsetColumn() { return arrayOffsetColumn; } public final ResolvedExpr getWhereExpr() { return whereExpr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(assertRowsModified); visitor.descend(arrayOffsetColumn); visitor.descend(whereExpr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (tableScan != null) { fields.add(new DebugStringField("table_scan", tableScan)); } if (assertRowsModified != null) { fields.add(new DebugStringField("assert_rows_modified", assertRowsModified)); } if (arrayOffsetColumn != null) { fields.add(new DebugStringField("array_offset_column", arrayOffsetColumn)); } if (whereExpr != null) { fields.add(new DebugStringField("where_expr", whereExpr)); } } } /** * This represents one item inside the SET clause of an UPDATE. * *

The entity being updated is specified by . * *

For a regular * SET {target} = {expression} | DEFAULT * clause (not including an array element update like SET a[OFFSET(0)] = 5), * and will be present, and all other fields will be * unset. * *

For an array element update (e.g. SET a.b[].c = ), * - is set to the array, * - is a new ResolvedColumn that can be used inside the * update items to refer to the array element. * - will have a node corresponding to the offset into * that array and the modification to that array element. * For example, for SET a.b[].c = , we have * ResolvedUpdateItem * +- = a.b * +- = * +- * +-ResolvedUpdateArrayItem * +- = * +- = ResolvedUpdateItem * +- = .c * +- = * *

The engine is required to fail the update if there are two elements of * corresponding to offset expressions that evaluate to * the same value. These are considered to be conflicting updates. * *

Multiple updates to the same array are always represented as multiple * elements of under a single ResolvedUpdateItem * corresponding to that array. will only have one * element for modifications to an array-valued subfield of an array element. * E.g., for SET a[].b[] = 5, a[].b[] = 6, we * will have: * ResolvedUpdateItem * +- = a * +- = x * +- * +-ResolvedUpdateArrayItem * +- = * +-ResolvedUpdateItem for .b[] = 5 * +-ResolvedUpdateArrayItem * +- = * +-ResolvedUpdateItem for .b[] = 6 * The engine must give a runtime error if and evaluate to * the same thing. Notably, it does not have to understand that the * two ResolvedUpdateItems corresponding to "b" refer to the same array iff * and evaluate to the same thing. * *

TODO: Consider allowing the engine to execute an update like * SET a[].b = 1, a[].c = 2 even if == since * "b" and "c" do not overlap. Also consider allowing a more complex example * like SET a[].b[] = ..., * a[].b[].c[] = ... even if == , as long * as != in that case. * *

For nested DML, and will both be set, and one or * more of the nested statement lists will be non-empty. must have * ARRAY type, and introduces a ResolvedColumn representing * elements of that array. The nested statement lists will always be empty in * a ResolvedUpdateItem child of a ResolvedUpdateArrayItem node. * *

See (broken link) for more detail. */ public static final class ResolvedUpdateItem extends ResolvedArgument { /** * The target entity to be updated. * *

This is an expression evaluated using the ResolvedColumns visible * inside this statement. This expression can contain only * ResolvedColumnRefs, ResolvedGetProtoField and * ResolvedGetStructField nodes. * *

In a top-level UPDATE, the expression always starts with a * ResolvedColumnRef referencing a column from the statement's * TableScan. * *

In a nested UPDATE, the expression always starts with a * ResolvedColumnRef referencing the element_column from the * ResolvedUpdateItem containing this scan. * *

This node is also used to represent a modification of a single * array element (when it occurs as a child of a * ResolvedUpdateArrayItem node). In that case, the expression * starts with a ResolvedColumnRef referencing the * from its grandparent ResolvedUpdateItem. (E.g., for "SET a[] * = 5", the grandparent ResolvedUpdateItem has "a", the * parent ResolvedUpdateArrayItem has offset , and this node * has 5 and target corresponding to the grandparent's * field.) * *

For either a nested UPDATE or an array modification, there may be * a path of field accesses after the initial ResolvedColumnRef, * represented by a chain of GetField nodes. * *

NOTE: We use the same GetField nodes as we do for queries, but * they are not treated the same. Here, they express a path inside * an object that is being mutated, so they have reference semantics. */ private final ResolvedExpr target; /** * Set the target entity to this value. The types must match. * This can contain the same columns that can appear in the * of the enclosing ResolvedUpdateStmt. * *

This is mutually exclusive with all fields below, which are used * for nested updates only. */ private final ResolvedDMLValue setValue; /** * The ResolvedColumn introduced to represent the elements of the * array being updated. This works similarly to * ArrayScan::element_column. * *

must have array type, and this column has the array's * element type. * *

This column can be referenced inside the nested statements below. */ private final ResolvedColumnHolder elementColumn; /** * Array element modifications to apply. Each item runs on the value * of specified by ResolvedUpdateArrayItem.offset. * This field is always empty if the analyzer option * FEATURE_V_1_2_ARRAY_ELEMENTS_WITH_SET is disabled. * *

The engine must fail if two elements in this list have offset * expressions that evaluate to the same value. * TODO: Consider generalizing this to allow * SET a[].b = ..., a[].c = ... */ private final ImmutableList arrayUpdateList; /** * Nested DELETE statements to apply. Each delete runs on one value * of and may choose to delete that array element. * *

DELETEs are applied before INSERTs or UPDATEs. * *

It is legal for the same input element to match multiple DELETEs. */ private final ImmutableList deleteList; /** * Nested UPDATE statements to apply. Each update runs on one value * of and may choose to update that array element. * *

UPDATEs are applied after DELETEs and before INSERTs. * *

It is an error if any element is matched by multiple UPDATEs. */ private final ImmutableList updateList; /** * Nested INSERT statements to apply. Each insert will produce zero * or more values for . * *

INSERTs are applied after DELETEs and UPDATEs. * *

For nested UPDATEs, insert_mode will always be the default, and * has no effect. */ private final ImmutableList insertList; protected ResolvedUpdateItem(ResolvedUpdateItemProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasTarget()) { target = ResolvedExpr.deserialize(proto.getTarget(), helper); } else { target = null; } if (proto.hasSetValue()) { setValue = ResolvedDMLValue.deserialize(proto.getSetValue(), helper); } else { setValue = null; } if (proto.hasElementColumn()) { elementColumn = ResolvedColumnHolder.deserialize(proto.getElementColumn(), helper); } else { elementColumn = null; } ImmutableList.Builder arrayUpdateListBuilder = ImmutableList.builder(); for (ResolvedUpdateArrayItemProto element : proto.getArrayUpdateListList()) { arrayUpdateListBuilder .add(ResolvedUpdateArrayItem.deserialize(element, helper)); } arrayUpdateList = arrayUpdateListBuilder.build(); ImmutableList.Builder deleteListBuilder = ImmutableList.builder(); for (ResolvedDeleteStmtProto element : proto.getDeleteListList()) { deleteListBuilder .add(ResolvedDeleteStmt.deserialize(element, helper)); } deleteList = deleteListBuilder.build(); ImmutableList.Builder updateListBuilder = ImmutableList.builder(); for (ResolvedUpdateStmtProto element : proto.getUpdateListList()) { updateListBuilder .add(ResolvedUpdateStmt.deserialize(element, helper)); } updateList = updateListBuilder.build(); ImmutableList.Builder insertListBuilder = ImmutableList.builder(); for (ResolvedInsertStmtProto element : proto.getInsertListList()) { insertListBuilder .add(ResolvedInsertStmt.deserialize(element, helper)); } insertList = insertListBuilder.build(); } public static final ResolvedUpdateItem deserialize( ResolvedUpdateItemProto proto, DeserializationHelper helper) { return new ResolvedUpdateItem(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_UPDATE_ITEM; } @Override public final String nodeKindString() { return "UpdateItem"; } /** * 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(); ResolvedUpdateItemProto.Builder childBuilder = ResolvedUpdateItemProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedUpdateItemNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedUpdateItemProto.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, ResolvedUpdateItemProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // target is an AST node. Call its serialization chain. if (this.getTarget() != null) { AnyResolvedExprProto.Builder targetBuilder = AnyResolvedExprProto.newBuilder(); this.getTarget().serialize( fileDescriptorSetsBuilder, targetBuilder); proto.setTarget( targetBuilder.build()); } // setValue is an AST node. Call its serialization chain. if (this.getSetValue() != null) { ResolvedDMLValueProto.Builder setValueBuilder = ResolvedDMLValueProto.newBuilder(); this.getSetValue().serialize( fileDescriptorSetsBuilder, setValueBuilder); proto.setSetValue( setValueBuilder.build()); } // elementColumn is an AST node. Call its serialization chain. if (this.getElementColumn() != null) { ResolvedColumnHolderProto.Builder elementColumnBuilder = ResolvedColumnHolderProto.newBuilder(); this.getElementColumn().serialize( fileDescriptorSetsBuilder, elementColumnBuilder); proto.setElementColumn( elementColumnBuilder.build()); } // arrayUpdateList is a collection of AST nodes. Serialize each of them. ImmutableList arrayUpdateLists = this.getArrayUpdateList(); for (ResolvedUpdateArrayItem element : arrayUpdateLists) { ResolvedUpdateArrayItemProto.Builder arrayUpdateListBuilder = ResolvedUpdateArrayItemProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, arrayUpdateListBuilder); proto.addArrayUpdateList(arrayUpdateListBuilder.build()); } // deleteList is a collection of AST nodes. Serialize each of them. ImmutableList deleteLists = this.getDeleteList(); for (ResolvedDeleteStmt element : deleteLists) { ResolvedDeleteStmtProto.Builder deleteListBuilder = ResolvedDeleteStmtProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, deleteListBuilder); proto.addDeleteList(deleteListBuilder.build()); } // updateList is a collection of AST nodes. Serialize each of them. ImmutableList updateLists = this.getUpdateList(); for (ResolvedUpdateStmt element : updateLists) { ResolvedUpdateStmtProto.Builder updateListBuilder = ResolvedUpdateStmtProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, updateListBuilder); proto.addUpdateList(updateListBuilder.build()); } // insertList is a collection of AST nodes. Serialize each of them. ImmutableList insertLists = this.getInsertList(); for (ResolvedInsertStmt element : insertLists) { ResolvedInsertStmtProto.Builder insertListBuilder = ResolvedInsertStmtProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, insertListBuilder); proto.addInsertList(insertListBuilder.build()); } } /** * The target entity to be updated. * *

This is an expression evaluated using the ResolvedColumns visible * inside this statement. This expression can contain only * ResolvedColumnRefs, ResolvedGetProtoField and * ResolvedGetStructField nodes. * *

In a top-level UPDATE, the expression always starts with a * ResolvedColumnRef referencing a column from the statement's * TableScan. * *

In a nested UPDATE, the expression always starts with a * ResolvedColumnRef referencing the element_column from the * ResolvedUpdateItem containing this scan. * *

This node is also used to represent a modification of a single * array element (when it occurs as a child of a * ResolvedUpdateArrayItem node). In that case, the expression * starts with a ResolvedColumnRef referencing the * from its grandparent ResolvedUpdateItem. (E.g., for "SET a[] * = 5", the grandparent ResolvedUpdateItem has "a", the * parent ResolvedUpdateArrayItem has offset , and this node * has 5 and target corresponding to the grandparent's * field.) * *

For either a nested UPDATE or an array modification, there may be * a path of field accesses after the initial ResolvedColumnRef, * represented by a chain of GetField nodes. * *

NOTE: We use the same GetField nodes as we do for queries, but * they are not treated the same. Here, they express a path inside * an object that is being mutated, so they have reference semantics. */ public final ResolvedExpr getTarget() { return target; } /** * Set the target entity to this value. The types must match. * This can contain the same columns that can appear in the * of the enclosing ResolvedUpdateStmt. * *

This is mutually exclusive with all fields below, which are used * for nested updates only. */ public final ResolvedDMLValue getSetValue() { return setValue; } /** * The ResolvedColumn introduced to represent the elements of the * array being updated. This works similarly to * ArrayScan::element_column. * *

must have array type, and this column has the array's * element type. * *

This column can be referenced inside the nested statements below. */ public final ResolvedColumnHolder getElementColumn() { return elementColumn; } /** * Array element modifications to apply. Each item runs on the value * of specified by ResolvedUpdateArrayItem.offset. * This field is always empty if the analyzer option * FEATURE_V_1_2_ARRAY_ELEMENTS_WITH_SET is disabled. * *

The engine must fail if two elements in this list have offset * expressions that evaluate to the same value. * TODO: Consider generalizing this to allow * SET a[].b = ..., a[].c = ... */ public final ImmutableList getArrayUpdateList() { return arrayUpdateList; } /** * Nested DELETE statements to apply. Each delete runs on one value * of and may choose to delete that array element. * *

DELETEs are applied before INSERTs or UPDATEs. * *

It is legal for the same input element to match multiple DELETEs. */ public final ImmutableList getDeleteList() { return deleteList; } /** * Nested UPDATE statements to apply. Each update runs on one value * of and may choose to update that array element. * *

UPDATEs are applied after DELETEs and before INSERTs. * *

It is an error if any element is matched by multiple UPDATEs. */ public final ImmutableList getUpdateList() { return updateList; } /** * Nested INSERT statements to apply. Each insert will produce zero * or more values for . * *

INSERTs are applied after DELETEs and UPDATEs. * *

For nested UPDATEs, insert_mode will always be the default, and * has no effect. */ public final ImmutableList getInsertList() { return insertList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(target); visitor.descend(setValue); visitor.descend(elementColumn); visitor.descend(arrayUpdateList); visitor.descend(deleteList); visitor.descend(updateList); visitor.descend(insertList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (target != null) { fields.add(new DebugStringField("target", target)); } if (setValue != null) { fields.add(new DebugStringField("set_value", setValue)); } if (elementColumn != null) { fields.add(new DebugStringField("element_column", elementColumn)); } if (!arrayUpdateList.isEmpty()) { fields.add(new DebugStringField("array_update_list", arrayUpdateList)); } if (!deleteList.isEmpty()) { fields.add(new DebugStringField("delete_list", deleteList)); } if (!updateList.isEmpty()) { fields.add(new DebugStringField("update_list", updateList)); } if (!insertList.isEmpty()) { fields.add(new DebugStringField("insert_list", insertList)); } } } /** * For an array element modification, this node represents the offset * expression and the modification, but not the array. E.g., for * SET a[] = 5, this node represents a modification of "= 5" to offset * of the array defined by the parent node. */ public static final class ResolvedUpdateArrayItem extends ResolvedArgument { /** * The array offset to be modified. */ private final ResolvedExpr offset; /** * The modification to perform to the array element. */ private final ResolvedUpdateItem updateItem; protected ResolvedUpdateArrayItem(ResolvedUpdateArrayItemProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasOffset()) { offset = ResolvedExpr.deserialize(proto.getOffset(), helper); } else { offset = null; } if (proto.hasUpdateItem()) { updateItem = ResolvedUpdateItem.deserialize(proto.getUpdateItem(), helper); } else { updateItem = null; } } public static final ResolvedUpdateArrayItem deserialize( ResolvedUpdateArrayItemProto proto, DeserializationHelper helper) { return new ResolvedUpdateArrayItem(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_UPDATE_ARRAY_ITEM; } @Override public final String nodeKindString() { return "UpdateArrayItem"; } /** * 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(); ResolvedUpdateArrayItemProto.Builder childBuilder = ResolvedUpdateArrayItemProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedUpdateArrayItemNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedUpdateArrayItemProto.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, ResolvedUpdateArrayItemProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // offset is an AST node. Call its serialization chain. if (this.getOffset() != null) { AnyResolvedExprProto.Builder offsetBuilder = AnyResolvedExprProto.newBuilder(); this.getOffset().serialize( fileDescriptorSetsBuilder, offsetBuilder); proto.setOffset( offsetBuilder.build()); } // updateItem is an AST node. Call its serialization chain. if (this.getUpdateItem() != null) { ResolvedUpdateItemProto.Builder updateItemBuilder = ResolvedUpdateItemProto.newBuilder(); this.getUpdateItem().serialize( fileDescriptorSetsBuilder, updateItemBuilder); proto.setUpdateItem( updateItemBuilder.build()); } } /** * The array offset to be modified. */ public final ResolvedExpr getOffset() { return offset; } /** * The modification to perform to the array element. */ public final ResolvedUpdateItem getUpdateItem() { return updateItem; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(offset); visitor.descend(updateItem); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (offset != null) { fields.add(new DebugStringField("offset", offset)); } if (updateItem != null) { fields.add(new DebugStringField("update_item", updateItem)); } } } /** * This represents an UPDATE statement, or a nested UPDATE inside an * UPDATE statement. * *

For top-level UPDATE statements, gives the table to * scan and creates ResolvedColumns for its columns. Those columns can be * referenced in the . The top-level UPDATE statement may * also have , the output of which is joined with * the using expressions in the . The columns * exposed in the are visible in the right side of the * expressions in the and in the . * is never set for top-level UPDATE statements. * *

Top-level UPDATE statements will also have populated. * For each column, this vector indicates if the column was read and/or * written. The columns in this vector match those of * . If a column was not encountered when producing * the resolved AST, then the value at that index will be * ResolvedStatement::NONE. * *

For nested UPDATEs, there is no . The can * only reference: * (1) the element_column from the ResolvedUpdateItem containing this * statement, * (2) columns from the outer statements, and * (3) (optionally) , which represents the 0-based * offset of the array element being modified. * The left hand sides of the expressions in can only * reference (1). The right hand sides of those expressions can reference * (1), (2), and (3). * *

The updates in will be non-overlapping. * If there are multiple nested statements updating the same entity, * they will be combined into one ResolvedUpdateItem. * *

See (broken link) for more detail on nested DML. */ public static final class ResolvedUpdateStmt extends ResolvedStatement { private final ResolvedTableScan tableScan; private final ImmutableList columnAccessList; private final ResolvedAssertRowsModified assertRowsModified; private final ResolvedColumnHolder arrayOffsetColumn; private final ResolvedExpr whereExpr; private final ImmutableList updateItemList; private final ResolvedScan fromScan; protected ResolvedUpdateStmt(ResolvedUpdateStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } columnAccessList = ImmutableList.copyOf(proto.getColumnAccessListList()); if (proto.hasAssertRowsModified()) { assertRowsModified = ResolvedAssertRowsModified.deserialize(proto.getAssertRowsModified(), helper); } else { assertRowsModified = null; } if (proto.hasArrayOffsetColumn()) { arrayOffsetColumn = ResolvedColumnHolder.deserialize(proto.getArrayOffsetColumn(), helper); } else { arrayOffsetColumn = null; } if (proto.hasWhereExpr()) { whereExpr = ResolvedExpr.deserialize(proto.getWhereExpr(), helper); } else { whereExpr = null; } ImmutableList.Builder updateItemListBuilder = ImmutableList.builder(); for (ResolvedUpdateItemProto element : proto.getUpdateItemListList()) { updateItemListBuilder .add(ResolvedUpdateItem.deserialize(element, helper)); } updateItemList = updateItemListBuilder.build(); if (proto.hasFromScan()) { fromScan = ResolvedScan.deserialize(proto.getFromScan(), helper); } else { fromScan = null; } } public static final ResolvedUpdateStmt deserialize( ResolvedUpdateStmtProto proto, DeserializationHelper helper) { return new ResolvedUpdateStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_UPDATE_STMT; } @Override public final String nodeKindString() { return "UpdateStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedUpdateStmtProto.Builder childBuilder = ResolvedUpdateStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedUpdateStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedUpdateStmtProto.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, ResolvedUpdateStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // tableScan is an AST node. Call its serialization chain. if (this.getTableScan() != null) { ResolvedTableScanProto.Builder tableScanBuilder = ResolvedTableScanProto.newBuilder(); this.getTableScan().serialize( fileDescriptorSetsBuilder, tableScanBuilder); proto.setTableScan( tableScanBuilder.build()); } // columnAccessList 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.addAllColumnAccessList(this.getColumnAccessList()); // assertRowsModified is an AST node. Call its serialization chain. if (this.getAssertRowsModified() != null) { ResolvedAssertRowsModifiedProto.Builder assertRowsModifiedBuilder = ResolvedAssertRowsModifiedProto.newBuilder(); this.getAssertRowsModified().serialize( fileDescriptorSetsBuilder, assertRowsModifiedBuilder); proto.setAssertRowsModified( assertRowsModifiedBuilder.build()); } // arrayOffsetColumn is an AST node. Call its serialization chain. if (this.getArrayOffsetColumn() != null) { ResolvedColumnHolderProto.Builder arrayOffsetColumnBuilder = ResolvedColumnHolderProto.newBuilder(); this.getArrayOffsetColumn().serialize( fileDescriptorSetsBuilder, arrayOffsetColumnBuilder); proto.setArrayOffsetColumn( arrayOffsetColumnBuilder.build()); } // whereExpr is an AST node. Call its serialization chain. if (this.getWhereExpr() != null) { AnyResolvedExprProto.Builder whereExprBuilder = AnyResolvedExprProto.newBuilder(); this.getWhereExpr().serialize( fileDescriptorSetsBuilder, whereExprBuilder); proto.setWhereExpr( whereExprBuilder.build()); } // updateItemList is a collection of AST nodes. Serialize each of them. ImmutableList updateItemLists = this.getUpdateItemList(); for (ResolvedUpdateItem element : updateItemLists) { ResolvedUpdateItemProto.Builder updateItemListBuilder = ResolvedUpdateItemProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, updateItemListBuilder); proto.addUpdateItemList(updateItemListBuilder.build()); } // fromScan is an AST node. Call its serialization chain. if (this.getFromScan() != null) { AnyResolvedScanProto.Builder fromScanBuilder = AnyResolvedScanProto.newBuilder(); this.getFromScan().serialize( fileDescriptorSetsBuilder, fromScanBuilder); proto.setFromScan( fromScanBuilder.build()); } } public final ResolvedTableScan getTableScan() { return tableScan; } public final ImmutableList getColumnAccessList() { return columnAccessList; } public final ResolvedAssertRowsModified getAssertRowsModified() { return assertRowsModified; } public final ResolvedColumnHolder getArrayOffsetColumn() { return arrayOffsetColumn; } public final ResolvedExpr getWhereExpr() { return whereExpr; } public final ImmutableList getUpdateItemList() { return updateItemList; } public final ResolvedScan getFromScan() { return fromScan; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(assertRowsModified); visitor.descend(arrayOffsetColumn); visitor.descend(whereExpr); visitor.descend(updateItemList); visitor.descend(fromScan); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (tableScan != null) { fields.add(new DebugStringField("table_scan", tableScan)); } if (!DebugStrings.isDefaultValue(columnAccessList)) { fields.add(new DebugStringField("column_access_list", DebugStrings.toStringObjectAccess(columnAccessList))); } if (assertRowsModified != null) { fields.add(new DebugStringField("assert_rows_modified", assertRowsModified)); } if (arrayOffsetColumn != null) { fields.add(new DebugStringField("array_offset_column", arrayOffsetColumn)); } if (whereExpr != null) { fields.add(new DebugStringField("where_expr", whereExpr)); } if (!updateItemList.isEmpty()) { fields.add(new DebugStringField("update_item_list", updateItemList)); } if (fromScan != null) { fields.add(new DebugStringField("from_scan", fromScan)); } } } /** * This is used by ResolvedMergeStmt to represent one WHEN ... THEN clause * within MERGE statement. * *

There are three types of clauses, which are MATCHED, NOT_MATCHED_BY_SOURCE * and NOT_MATCHED_BY_TARGET. The must have one of these values. * *

The defines an optional expression to apply to the join * result of and of the parent ResolvedMergeStmt. * *

Each ResolvedMergeWhen must define exactly one of three operations, * -- INSERT: is ResolvedMergeWhen::INSERT. * Both and are non-empty. * The size of must be the same with the * value_list size of , and, the column data type * must match. * -- UPDATE: is ResolvedMergeWhen::UPDATE. * is non-empty. * -- DELETE: is ResolvedMergeWhen::DELETE. * The INSERT, UPDATE and DELETE operations are mutually exclusive. * *

When is MATCHED, must be UPDATE or DELETE. * When is NOT_MATCHED_BY_TARGET, must be INSERT. * When is NOT_MATCHED_BY_SOURCE, must be UPDATE * or DELETE. * *

The column visibility within a ResolvedMergeWhen clause is defined as * following, * -- When is MATCHED, * -- All columns from and are allowed in * . * -- If is UPDATE, only columns from are * allowed on left side of expressions in . * All columns from and are allowed on right * side of expressions in . * -- When is NOT_MATCHED_BY_TARGET, * -- Only columns from are allowed in . * -- Only columns from are allowed in * . * -- Only columns from are allowed in . * -- When is NOT_MATCHED_BY_SOURCE, * -- Only columns from are allowed in . * -- If is UPDATE, only columns from are * allowed in . */ public static final class ResolvedMergeWhen extends ResolvedArgument { private final MatchType matchType; private final ResolvedExpr matchExpr; private final ActionType actionType; private final ImmutableList insertColumnList; private final ResolvedInsertRow insertRow; private final ImmutableList updateItemList; protected ResolvedMergeWhen(ResolvedMergeWhenProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); matchType = proto.getMatchType(); if (proto.hasMatchExpr()) { matchExpr = ResolvedExpr.deserialize(proto.getMatchExpr(), helper); } else { matchExpr = null; } actionType = proto.getActionType(); ImmutableList.Builder insertColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getInsertColumnListList()) { insertColumnListBuilder.add(helper.deserialize(element)); } insertColumnList = insertColumnListBuilder.build(); if (proto.hasInsertRow()) { insertRow = ResolvedInsertRow.deserialize(proto.getInsertRow(), helper); } else { insertRow = null; } ImmutableList.Builder updateItemListBuilder = ImmutableList.builder(); for (ResolvedUpdateItemProto element : proto.getUpdateItemListList()) { updateItemListBuilder .add(ResolvedUpdateItem.deserialize(element, helper)); } updateItemList = updateItemListBuilder.build(); } public static final ResolvedMergeWhen deserialize( ResolvedMergeWhenProto proto, DeserializationHelper helper) { return new ResolvedMergeWhen(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MERGE_WHEN; } @Override public final String nodeKindString() { return "MergeWhen"; } /** * 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(); ResolvedMergeWhenProto.Builder childBuilder = ResolvedMergeWhenProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMergeWhenNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMergeWhenProto.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, ResolvedMergeWhenProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // matchType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setMatchType(this.getMatchType()); // matchExpr is an AST node. Call its serialization chain. if (this.getMatchExpr() != null) { AnyResolvedExprProto.Builder matchExprBuilder = AnyResolvedExprProto.newBuilder(); this.getMatchExpr().serialize( fileDescriptorSetsBuilder, matchExprBuilder); proto.setMatchExpr( matchExprBuilder.build()); } // actionType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setActionType(this.getActionType()); // insertColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList insertColumnLists = this.getInsertColumnList(); for (ResolvedColumn element : insertColumnLists) { proto.addInsertColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // insertRow is an AST node. Call its serialization chain. if (this.getInsertRow() != null) { ResolvedInsertRowProto.Builder insertRowBuilder = ResolvedInsertRowProto.newBuilder(); this.getInsertRow().serialize( fileDescriptorSetsBuilder, insertRowBuilder); proto.setInsertRow( insertRowBuilder.build()); } // updateItemList is a collection of AST nodes. Serialize each of them. ImmutableList updateItemLists = this.getUpdateItemList(); for (ResolvedUpdateItem element : updateItemLists) { ResolvedUpdateItemProto.Builder updateItemListBuilder = ResolvedUpdateItemProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, updateItemListBuilder); proto.addUpdateItemList(updateItemListBuilder.build()); } } public final MatchType getMatchType() { return matchType; } public final ResolvedExpr getMatchExpr() { return matchExpr; } public final ActionType getActionType() { return actionType; } public final ImmutableList getInsertColumnList() { return insertColumnList; } public final ResolvedInsertRow getInsertRow() { return insertRow; } public final ImmutableList getUpdateItemList() { return updateItemList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(matchExpr); visitor.descend(insertRow); visitor.descend(updateItemList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("match_type", DebugStrings.toStringImpl(matchType))); } if (matchExpr != null) { fields.add(new DebugStringField("match_expr", matchExpr)); } { fields.add(new DebugStringField("action_type", DebugStrings.toStringImpl(actionType))); } if (!DebugStrings.isDefaultValue(insertColumnList)) { fields.add(new DebugStringField("insert_column_list", DebugStrings.toStringImpl(insertColumnList))); } if (insertRow != null) { fields.add(new DebugStringField("insert_row", insertRow)); } if (!updateItemList.isEmpty()) { fields.add(new DebugStringField("update_item_list", updateItemList)); } } } /** * This represents a MERGE statement. * *

gives the target table to scan and creates ResolvedColumns * for its columns. * *

indicates for each column, whether it was read and/or * written. The columns in this vector match those of * . If a column was not encountered when producing * the resolved AST, then the value at that index will be * ResolvedStatement::NONE(0). * *

The output of is joined with using the join * expression . * *

The order of elements in matters, as they are executed * sequentially. At most one of the clause will be applied * to each row from . * *

, , and are * required. must be non-empty. * *

See (broken link) for more detail on MERGE statement. */ public static final class ResolvedMergeStmt extends ResolvedStatement { private final ResolvedTableScan tableScan; private final ImmutableList columnAccessList; private final ResolvedScan fromScan; private final ResolvedExpr mergeExpr; private final ImmutableList whenClauseList; protected ResolvedMergeStmt(ResolvedMergeStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } columnAccessList = ImmutableList.copyOf(proto.getColumnAccessListList()); if (proto.hasFromScan()) { fromScan = ResolvedScan.deserialize(proto.getFromScan(), helper); } else { fromScan = null; } if (proto.hasMergeExpr()) { mergeExpr = ResolvedExpr.deserialize(proto.getMergeExpr(), helper); } else { mergeExpr = null; } ImmutableList.Builder whenClauseListBuilder = ImmutableList.builder(); for (ResolvedMergeWhenProto element : proto.getWhenClauseListList()) { whenClauseListBuilder .add(ResolvedMergeWhen.deserialize(element, helper)); } whenClauseList = whenClauseListBuilder.build(); } public static final ResolvedMergeStmt deserialize( ResolvedMergeStmtProto proto, DeserializationHelper helper) { return new ResolvedMergeStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MERGE_STMT; } @Override public final String nodeKindString() { return "MergeStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedMergeStmtProto.Builder childBuilder = ResolvedMergeStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMergeStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMergeStmtProto.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, ResolvedMergeStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // tableScan is an AST node. Call its serialization chain. if (this.getTableScan() != null) { ResolvedTableScanProto.Builder tableScanBuilder = ResolvedTableScanProto.newBuilder(); this.getTableScan().serialize( fileDescriptorSetsBuilder, tableScanBuilder); proto.setTableScan( tableScanBuilder.build()); } // columnAccessList 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.addAllColumnAccessList(this.getColumnAccessList()); // fromScan is an AST node. Call its serialization chain. if (this.getFromScan() != null) { AnyResolvedScanProto.Builder fromScanBuilder = AnyResolvedScanProto.newBuilder(); this.getFromScan().serialize( fileDescriptorSetsBuilder, fromScanBuilder); proto.setFromScan( fromScanBuilder.build()); } // mergeExpr is an AST node. Call its serialization chain. if (this.getMergeExpr() != null) { AnyResolvedExprProto.Builder mergeExprBuilder = AnyResolvedExprProto.newBuilder(); this.getMergeExpr().serialize( fileDescriptorSetsBuilder, mergeExprBuilder); proto.setMergeExpr( mergeExprBuilder.build()); } // whenClauseList is a collection of AST nodes. Serialize each of them. ImmutableList whenClauseLists = this.getWhenClauseList(); for (ResolvedMergeWhen element : whenClauseLists) { ResolvedMergeWhenProto.Builder whenClauseListBuilder = ResolvedMergeWhenProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, whenClauseListBuilder); proto.addWhenClauseList(whenClauseListBuilder.build()); } } public final ResolvedTableScan getTableScan() { return tableScan; } public final ImmutableList getColumnAccessList() { return columnAccessList; } public final ResolvedScan getFromScan() { return fromScan; } public final ResolvedExpr getMergeExpr() { return mergeExpr; } public final ImmutableList getWhenClauseList() { return whenClauseList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(fromScan); visitor.descend(mergeExpr); visitor.descend(whenClauseList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (tableScan != null) { fields.add(new DebugStringField("table_scan", tableScan)); } if (!DebugStrings.isDefaultValue(columnAccessList)) { fields.add(new DebugStringField("column_access_list", DebugStrings.toStringObjectAccess(columnAccessList))); } if (fromScan != null) { fields.add(new DebugStringField("from_scan", fromScan)); } if (mergeExpr != null) { fields.add(new DebugStringField("merge_expr", mergeExpr)); } if (!whenClauseList.isEmpty()) { fields.add(new DebugStringField("when_clause_list", whenClauseList)); } } } /** * This represents a TRUNCATE TABLE statement. * *

Statement: * TRUNCATE TABLE [WHERE ] * *

is a TableScan for the target table, which is used during * resolving and validation. Consumers can use either the table * object inside it or name_path to reference the table. * boolean expression that can reference columns in * ResolvedColumns (which the TableScan creates); the * should always correspond to entire partitions, * and is optional. */ public static final class ResolvedTruncateStmt extends ResolvedStatement { private final ResolvedTableScan tableScan; private final ResolvedExpr whereExpr; protected ResolvedTruncateStmt(ResolvedTruncateStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } if (proto.hasWhereExpr()) { whereExpr = ResolvedExpr.deserialize(proto.getWhereExpr(), helper); } else { whereExpr = null; } } public static final ResolvedTruncateStmt deserialize( ResolvedTruncateStmtProto proto, DeserializationHelper helper) { return new ResolvedTruncateStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_TRUNCATE_STMT; } @Override public final String nodeKindString() { return "TruncateStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedTruncateStmtProto.Builder childBuilder = ResolvedTruncateStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedTruncateStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedTruncateStmtProto.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, ResolvedTruncateStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // tableScan is an AST node. Call its serialization chain. if (this.getTableScan() != null) { ResolvedTableScanProto.Builder tableScanBuilder = ResolvedTableScanProto.newBuilder(); this.getTableScan().serialize( fileDescriptorSetsBuilder, tableScanBuilder); proto.setTableScan( tableScanBuilder.build()); } // whereExpr is an AST node. Call its serialization chain. if (this.getWhereExpr() != null) { AnyResolvedExprProto.Builder whereExprBuilder = AnyResolvedExprProto.newBuilder(); this.getWhereExpr().serialize( fileDescriptorSetsBuilder, whereExprBuilder); proto.setWhereExpr( whereExprBuilder.build()); } } public final ResolvedTableScan getTableScan() { return tableScan; } public final ResolvedExpr getWhereExpr() { return whereExpr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(whereExpr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (tableScan != null) { fields.add(new DebugStringField("table_scan", tableScan)); } if (whereExpr != null) { fields.add(new DebugStringField("where_expr", whereExpr)); } } } /** * A grantable privilege. * *

is the type of privilege action, e.g. SELECT, INSERT, UPDATE * or DELETE. * is an optional list of units of the object (e.g. columns of a * table) the privilege is restricted to. Privilege on the whole object * should be granted/revoked if the list is empty. */ public static final class ResolvedPrivilege extends ResolvedArgument { private final String actionType; private final ImmutableList unitList; protected ResolvedPrivilege(ResolvedPrivilegeProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); actionType = proto.getActionType(); unitList = ImmutableList.copyOf(proto.getUnitListList()); } public static final ResolvedPrivilege deserialize( ResolvedPrivilegeProto proto, DeserializationHelper helper) { return new ResolvedPrivilege(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PRIVILEGE; } @Override public final String nodeKindString() { return "Privilege"; } /** * 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(); ResolvedPrivilegeProto.Builder childBuilder = ResolvedPrivilegeProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedPrivilegeNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedPrivilegeProto.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, ResolvedPrivilegeProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // actionType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setActionType(this.getActionType()); // unitList 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.addAllUnitList(this.getUnitList()); } public final String getActionType() { return actionType; } public final ImmutableList getUnitList() { return unitList; } @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("action_type", DebugStrings.toStringImpl(actionType))); } { fields.add(new DebugStringField("unit_list", DebugStrings.toStringImpl(unitList))); } } } /** * Common superclass of GRANT/REVOKE statements. * *

is the list of privileges to be granted/revoked. ALL * PRIVILEGES should be granted/fromed if it is empty. * is an optional string identifier, e.g., TABLE, VIEW. * is a vector of segments of the object identifier's pathname. * (DEPRECATED) is the list of grantees (strings). * is the list of grantees, and may include parameters. * *

Only one of or will be populated, * depending on whether or not the FEATURE_PARAMETERS_IN_GRANTEE_LIST * is enabled. The is deprecated, and will be removed * along with the corresponding FEATURE once all engines have migrated to * use the . Once is the only * one, then it should be marked as NOT_IGNORABLE. */ public static abstract class ResolvedGrantOrRevokeStmt extends ResolvedStatement { private final ImmutableList privilegeList; private final String objectType; private final ImmutableList namePath; private final ImmutableList granteeList; private final ImmutableList granteeExprList; protected ResolvedGrantOrRevokeStmt(ResolvedGrantOrRevokeStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder privilegeListBuilder = ImmutableList.builder(); for (ResolvedPrivilegeProto element : proto.getPrivilegeListList()) { privilegeListBuilder .add(ResolvedPrivilege.deserialize(element, helper)); } privilegeList = privilegeListBuilder.build(); objectType = proto.getObjectType(); namePath = ImmutableList.copyOf(proto.getNamePathList()); granteeList = ImmutableList.copyOf(proto.getGranteeListList()); ImmutableList.Builder granteeExprListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getGranteeExprListList()) { granteeExprListBuilder .add(ResolvedExpr.deserialize(element, helper)); } granteeExprList = granteeExprListBuilder.build(); } public static ResolvedGrantOrRevokeStmt deserialize( AnyResolvedGrantOrRevokeStmtProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_GRANT_STMT_NODE: return ResolvedGrantStmt.deserialize( proto.getResolvedGrantStmtNode(), helper); case RESOLVED_REVOKE_STMT_NODE: return ResolvedRevokeStmt.deserialize( proto.getResolvedRevokeStmtNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedGrantOrRevokeStmtProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedGrantOrRevokeStmtProto.Builder builder = ResolvedGrantOrRevokeStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); AnyResolvedGrantOrRevokeStmtProto.Builder childBuilder = AnyResolvedGrantOrRevokeStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGrantOrRevokeStmtNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedGrantOrRevokeStmtProto.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, AnyResolvedGrantOrRevokeStmtProto.Builder builder); /** * Serializes this node into the given {@link ResolvedGrantOrRevokeStmtProto.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, ResolvedGrantOrRevokeStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // privilegeList is a collection of AST nodes. Serialize each of them. ImmutableList privilegeLists = this.getPrivilegeList(); for (ResolvedPrivilege element : privilegeLists) { ResolvedPrivilegeProto.Builder privilegeListBuilder = ResolvedPrivilegeProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, privilegeListBuilder); proto.addPrivilegeList(privilegeListBuilder.build()); } // objectType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setObjectType(this.getObjectType()); // 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()); // granteeList 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.addAllGranteeList(this.getGranteeList()); // granteeExprList is a collection of AST nodes. Serialize each of them. ImmutableList granteeExprLists = this.getGranteeExprList(); for (ResolvedExpr element : granteeExprLists) { AnyResolvedExprProto.Builder granteeExprListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, granteeExprListBuilder); proto.addGranteeExprList(granteeExprListBuilder.build()); } } public final ImmutableList getPrivilegeList() { return privilegeList; } public final String getObjectType() { return objectType; } public final ImmutableList getNamePath() { return namePath; } public final ImmutableList getGranteeList() { return granteeList; } public final ImmutableList getGranteeExprList() { return granteeExprList; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(privilegeList); visitor.descend(granteeExprList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!privilegeList.isEmpty()) { fields.add(new DebugStringField("privilege_list", privilegeList)); } { fields.add(new DebugStringField("object_type", DebugStrings.toStringImpl(objectType))); } { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!DebugStrings.isDefaultValue(granteeList)) { fields.add(new DebugStringField("grantee_list", DebugStrings.toStringCommaSeparated(granteeList))); } if (!granteeExprList.isEmpty()) { fields.add(new DebugStringField("grantee_expr_list", granteeExprList)); } } } /** * A GRANT statement. It represents the action to grant a list of privileges * on a specific object to/from list of grantees. */ public static final class ResolvedGrantStmt extends ResolvedGrantOrRevokeStmt { protected ResolvedGrantStmt(ResolvedGrantStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedGrantStmt deserialize( ResolvedGrantStmtProto proto, DeserializationHelper helper) { return new ResolvedGrantStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRANT_STMT; } @Override public final String nodeKindString() { return "GrantStmt"; } /** * Serializes this node into a {@link AnyResolvedGrantOrRevokeStmtProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGrantOrRevokeStmtProto.Builder builder = AnyResolvedGrantOrRevokeStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGrantOrRevokeStmtProto.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, AnyResolvedGrantOrRevokeStmtProto.Builder builder) { builder.clear(); ResolvedGrantStmtProto.Builder childBuilder = ResolvedGrantStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGrantStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGrantStmtProto.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, ResolvedGrantStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGrantOrRevokeStmtProto parent = (ResolvedGrantOrRevokeStmtProto) 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); } } /** * A REVOKE statement. It represents the action to revoke a list of * privileges on a specific object to/from list of grantees. */ public static final class ResolvedRevokeStmt extends ResolvedGrantOrRevokeStmt { protected ResolvedRevokeStmt(ResolvedRevokeStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedRevokeStmt deserialize( ResolvedRevokeStmtProto proto, DeserializationHelper helper) { return new ResolvedRevokeStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_REVOKE_STMT; } @Override public final String nodeKindString() { return "RevokeStmt"; } /** * Serializes this node into a {@link AnyResolvedGrantOrRevokeStmtProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGrantOrRevokeStmtProto.Builder builder = AnyResolvedGrantOrRevokeStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGrantOrRevokeStmtProto.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, AnyResolvedGrantOrRevokeStmtProto.Builder builder) { builder.clear(); ResolvedRevokeStmtProto.Builder childBuilder = ResolvedRevokeStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRevokeStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRevokeStmtProto.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, ResolvedRevokeStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGrantOrRevokeStmtProto parent = (ResolvedGrantOrRevokeStmtProto) 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); } } /** * Common super class for statements: * ALTER [IF EXISTS] * *

is a vector giving the identifier path in the table . * is a vector of actions to be done to the object. * silently ignores the "name_path does not exist" error. */ public static abstract class ResolvedAlterObjectStmt extends ResolvedStatement { private final ImmutableList namePath; private final ImmutableList alterActionList; private final boolean isIfExists; protected ResolvedAlterObjectStmt(ResolvedAlterObjectStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); ImmutableList.Builder alterActionListBuilder = ImmutableList.builder(); for (AnyResolvedAlterActionProto element : proto.getAlterActionListList()) { alterActionListBuilder .add(ResolvedAlterAction.deserialize(element, helper)); } alterActionList = alterActionListBuilder.build(); isIfExists = proto.getIsIfExists(); } public static ResolvedAlterObjectStmt deserialize( AnyResolvedAlterObjectStmtProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_ALTER_ROW_ACCESS_POLICY_STMT_NODE: return ResolvedAlterRowAccessPolicyStmt.deserialize( proto.getResolvedAlterRowAccessPolicyStmtNode(), helper); case RESOLVED_ALTER_TABLE_STMT_NODE: return ResolvedAlterTableStmt.deserialize( proto.getResolvedAlterTableStmtNode(), helper); case RESOLVED_ALTER_VIEW_STMT_NODE: return ResolvedAlterViewStmt.deserialize( proto.getResolvedAlterViewStmtNode(), helper); case RESOLVED_ALTER_MATERIALIZED_VIEW_STMT_NODE: return ResolvedAlterMaterializedViewStmt.deserialize( proto.getResolvedAlterMaterializedViewStmtNode(), helper); case RESOLVED_ALTER_DATABASE_STMT_NODE: return ResolvedAlterDatabaseStmt.deserialize( proto.getResolvedAlterDatabaseStmtNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedAlterObjectStmtProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedAlterObjectStmtProto.Builder builder = ResolvedAlterObjectStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); AnyResolvedAlterObjectStmtProto.Builder childBuilder = AnyResolvedAlterObjectStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterObjectStmtNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedAlterObjectStmtProto.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, AnyResolvedAlterObjectStmtProto.Builder builder); /** * Serializes this node into the given {@link ResolvedAlterObjectStmtProto.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, ResolvedAlterObjectStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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()); // alterActionList is a collection of AST nodes. Serialize each of them. ImmutableList alterActionLists = this.getAlterActionList(); for (ResolvedAlterAction element : alterActionLists) { AnyResolvedAlterActionProto.Builder alterActionListBuilder = AnyResolvedAlterActionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, alterActionListBuilder); proto.addAlterActionList(alterActionListBuilder.build()); } // isIfExists is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsIfExists(this.getIsIfExists()); } public final ImmutableList getNamePath() { return namePath; } public final ImmutableList getAlterActionList() { return alterActionList; } public final boolean getIsIfExists() { return isIfExists; } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(alterActionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!alterActionList.isEmpty()) { fields.add(new DebugStringField("alter_action_list", alterActionList)); } if (!DebugStrings.isDefaultValue(isIfExists)) { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } } } /** * This statement: * ALTER DATABASE [IF EXISTS] * *

This statement could be used to change the database level options. */ public static final class ResolvedAlterDatabaseStmt extends ResolvedAlterObjectStmt { protected ResolvedAlterDatabaseStmt(ResolvedAlterDatabaseStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedAlterDatabaseStmt deserialize( ResolvedAlterDatabaseStmtProto proto, DeserializationHelper helper) { return new ResolvedAlterDatabaseStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_DATABASE_STMT; } @Override public final String nodeKindString() { return "AlterDatabaseStmt"; } /** * Serializes this node into a {@link AnyResolvedAlterObjectStmtProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterObjectStmtProto.Builder builder = AnyResolvedAlterObjectStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterObjectStmtProto.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, AnyResolvedAlterObjectStmtProto.Builder builder) { builder.clear(); ResolvedAlterDatabaseStmtProto.Builder childBuilder = ResolvedAlterDatabaseStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterDatabaseStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterDatabaseStmtProto.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, ResolvedAlterDatabaseStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterObjectStmtProto parent = (ResolvedAlterObjectStmtProto) 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); } } /** * This statement: * ALTER MATERIALIZED VIEW [IF EXISTS] */ public static final class ResolvedAlterMaterializedViewStmt extends ResolvedAlterObjectStmt { protected ResolvedAlterMaterializedViewStmt(ResolvedAlterMaterializedViewStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedAlterMaterializedViewStmt deserialize( ResolvedAlterMaterializedViewStmtProto proto, DeserializationHelper helper) { return new ResolvedAlterMaterializedViewStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_MATERIALIZED_VIEW_STMT; } @Override public final String nodeKindString() { return "AlterMaterializedViewStmt"; } /** * Serializes this node into a {@link AnyResolvedAlterObjectStmtProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterObjectStmtProto.Builder builder = AnyResolvedAlterObjectStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterObjectStmtProto.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, AnyResolvedAlterObjectStmtProto.Builder builder) { builder.clear(); ResolvedAlterMaterializedViewStmtProto.Builder childBuilder = ResolvedAlterMaterializedViewStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterMaterializedViewStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterMaterializedViewStmtProto.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, ResolvedAlterMaterializedViewStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterObjectStmtProto parent = (ResolvedAlterObjectStmtProto) 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); } } /** * This statement: * ALTER TABLE [IF EXISTS] */ public static final class ResolvedAlterTableStmt extends ResolvedAlterObjectStmt { protected ResolvedAlterTableStmt(ResolvedAlterTableStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedAlterTableStmt deserialize( ResolvedAlterTableStmtProto proto, DeserializationHelper helper) { return new ResolvedAlterTableStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_TABLE_STMT; } @Override public final String nodeKindString() { return "AlterTableStmt"; } /** * Serializes this node into a {@link AnyResolvedAlterObjectStmtProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterObjectStmtProto.Builder builder = AnyResolvedAlterObjectStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterObjectStmtProto.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, AnyResolvedAlterObjectStmtProto.Builder builder) { builder.clear(); ResolvedAlterTableStmtProto.Builder childBuilder = ResolvedAlterTableStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterTableStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterTableStmtProto.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, ResolvedAlterTableStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterObjectStmtProto parent = (ResolvedAlterObjectStmtProto) 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); } } /** * This statement: * ALTER VIEW [IF EXISTS] */ public static final class ResolvedAlterViewStmt extends ResolvedAlterObjectStmt { protected ResolvedAlterViewStmt(ResolvedAlterViewStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static final ResolvedAlterViewStmt deserialize( ResolvedAlterViewStmtProto proto, DeserializationHelper helper) { return new ResolvedAlterViewStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_VIEW_STMT; } @Override public final String nodeKindString() { return "AlterViewStmt"; } /** * Serializes this node into a {@link AnyResolvedAlterObjectStmtProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterObjectStmtProto.Builder builder = AnyResolvedAlterObjectStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterObjectStmtProto.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, AnyResolvedAlterObjectStmtProto.Builder builder) { builder.clear(); ResolvedAlterViewStmtProto.Builder childBuilder = ResolvedAlterViewStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterViewStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterViewStmtProto.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, ResolvedAlterViewStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterObjectStmtProto parent = (ResolvedAlterObjectStmtProto) 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); } } /** * A common super class for all actions in statement ALTER */ public static abstract class ResolvedAlterAction extends ResolvedArgument { protected ResolvedAlterAction(ResolvedAlterActionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); } public static ResolvedAlterAction deserialize( AnyResolvedAlterActionProto proto, DeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_SET_OPTIONS_ACTION_NODE: return ResolvedSetOptionsAction.deserialize( proto.getResolvedSetOptionsActionNode(), helper); case RESOLVED_ADD_COLUMN_ACTION_NODE: return ResolvedAddColumnAction.deserialize( proto.getResolvedAddColumnActionNode(), helper); case RESOLVED_DROP_COLUMN_ACTION_NODE: return ResolvedDropColumnAction.deserialize( proto.getResolvedDropColumnActionNode(), helper); case RESOLVED_GRANT_TO_ACTION_NODE: return ResolvedGrantToAction.deserialize( proto.getResolvedGrantToActionNode(), helper); case RESOLVED_FILTER_USING_ACTION_NODE: return ResolvedFilterUsingAction.deserialize( proto.getResolvedFilterUsingActionNode(), helper); case RESOLVED_REVOKE_FROM_ACTION_NODE: return ResolvedRevokeFromAction.deserialize( proto.getResolvedRevokeFromActionNode(), helper); case RESOLVED_RENAME_TO_ACTION_NODE: return ResolvedRenameToAction.deserialize( proto.getResolvedRenameToActionNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedAlterActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedAlterActionProto.Builder builder = ResolvedAlterActionProto.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(); AnyResolvedAlterActionProto.Builder childBuilder = AnyResolvedAlterActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterActionNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedAlterActionProto.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, AnyResolvedAlterActionProto.Builder builder); /** * Serializes this node into the given {@link ResolvedAlterActionProto.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, ResolvedAlterActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * SET OPTIONS action for ALTER statement * *

has engine-specific directives that specify how to * alter the metadata for this object. */ public static final class ResolvedSetOptionsAction extends ResolvedAlterAction { private final ImmutableList optionList; protected ResolvedSetOptionsAction(ResolvedSetOptionsActionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } public static final ResolvedSetOptionsAction deserialize( ResolvedSetOptionsActionProto proto, DeserializationHelper helper) { return new ResolvedSetOptionsAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SET_OPTIONS_ACTION; } @Override public final String nodeKindString() { return "SetOptionsAction"; } /** * Serializes this node into a {@link AnyResolvedAlterActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterActionProto.Builder builder = AnyResolvedAlterActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterActionProto.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, AnyResolvedAlterActionProto.Builder builder) { builder.clear(); ResolvedSetOptionsActionProto.Builder childBuilder = ResolvedSetOptionsActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSetOptionsActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSetOptionsActionProto.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, ResolvedSetOptionsActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * ADD COLUMN action for ALTER TABLE statement */ public static final class ResolvedAddColumnAction extends ResolvedAlterAction { private final boolean isIfNotExists; private final ResolvedColumnDefinition columnDefinition; protected ResolvedAddColumnAction(ResolvedAddColumnActionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); isIfNotExists = proto.getIsIfNotExists(); if (proto.hasColumnDefinition()) { columnDefinition = ResolvedColumnDefinition.deserialize(proto.getColumnDefinition(), helper); } else { columnDefinition = null; } } public static final ResolvedAddColumnAction deserialize( ResolvedAddColumnActionProto proto, DeserializationHelper helper) { return new ResolvedAddColumnAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ADD_COLUMN_ACTION; } @Override public final String nodeKindString() { return "AddColumnAction"; } /** * Serializes this node into a {@link AnyResolvedAlterActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterActionProto.Builder builder = AnyResolvedAlterActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterActionProto.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, AnyResolvedAlterActionProto.Builder builder) { builder.clear(); ResolvedAddColumnActionProto.Builder childBuilder = ResolvedAddColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAddColumnActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAddColumnActionProto.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, ResolvedAddColumnActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // isIfNotExists is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsIfNotExists(this.getIsIfNotExists()); // columnDefinition is an AST node. Call its serialization chain. if (this.getColumnDefinition() != null) { ResolvedColumnDefinitionProto.Builder columnDefinitionBuilder = ResolvedColumnDefinitionProto.newBuilder(); this.getColumnDefinition().serialize( fileDescriptorSetsBuilder, columnDefinitionBuilder); proto.setColumnDefinition( columnDefinitionBuilder.build()); } } public final boolean getIsIfNotExists() { return isIfNotExists; } public final ResolvedColumnDefinition getColumnDefinition() { return columnDefinition; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnDefinition); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("is_if_not_exists", DebugStrings.toStringImpl(isIfNotExists))); } if (columnDefinition != null) { fields.add(new DebugStringField("column_definition", columnDefinition)); } } } /** * DROP COLUMN action for ALTER TABLE statement * *

is the name of the column to drop. * references the column to be dropped, if it exists. * It might be missing if DROP IF EXISTS column does not exist. */ public static final class ResolvedDropColumnAction extends ResolvedAlterAction { private final boolean isIfExists; private final String name; private final ResolvedColumnRef columnReference; protected ResolvedDropColumnAction(ResolvedDropColumnActionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); name = proto.getName(); if (proto.hasColumnReference()) { columnReference = ResolvedColumnRef.deserialize(proto.getColumnReference(), helper); } else { columnReference = null; } } public static final ResolvedDropColumnAction deserialize( ResolvedDropColumnActionProto proto, DeserializationHelper helper) { return new ResolvedDropColumnAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_COLUMN_ACTION; } @Override public final String nodeKindString() { return "DropColumnAction"; } /** * Serializes this node into a {@link AnyResolvedAlterActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterActionProto.Builder builder = AnyResolvedAlterActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterActionProto.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, AnyResolvedAlterActionProto.Builder builder) { builder.clear(); ResolvedDropColumnActionProto.Builder childBuilder = ResolvedDropColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropColumnActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropColumnActionProto.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, ResolvedDropColumnActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // isIfExists is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsIfExists(this.getIsIfExists()); // 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()); // columnReference is an AST node. Call its serialization chain. if (this.getColumnReference() != null) { ResolvedColumnRefProto.Builder columnReferenceBuilder = ResolvedColumnRefProto.newBuilder(); this.getColumnReference().serialize( fileDescriptorSetsBuilder, columnReferenceBuilder); proto.setColumnReference( columnReferenceBuilder.build()); } } public final boolean getIsIfExists() { return isIfExists; } public final String getName() { return name; } public final ResolvedColumnRef getColumnReference() { return columnReference; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnReference); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (columnReference != null) { fields.add(new DebugStringField("column_reference", columnReference)); } } } /** * This statement: * ALTER TABLE [IF EXISTS] SET OPTIONS (...) * *

NOTE: This is deprecated in favor of ResolvedAlterTableStmt. * *

is a vector giving the identifier path in the table . * has engine-specific directives that specify how to * alter the metadata for this table. * silently ignore the "name_path does not exist" error. */ public static final class ResolvedAlterTableSetOptionsStmt extends ResolvedStatement { private final ImmutableList namePath; private final ImmutableList optionList; private final boolean isIfExists; protected ResolvedAlterTableSetOptionsStmt(ResolvedAlterTableSetOptionsStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); isIfExists = proto.getIsIfExists(); } public static final ResolvedAlterTableSetOptionsStmt deserialize( ResolvedAlterTableSetOptionsStmtProto proto, DeserializationHelper helper) { return new ResolvedAlterTableSetOptionsStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_TABLE_SET_OPTIONS_STMT; } @Override public final String nodeKindString() { return "AlterTableSetOptionsStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedAlterTableSetOptionsStmtProto.Builder childBuilder = ResolvedAlterTableSetOptionsStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterTableSetOptionsStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterTableSetOptionsStmtProto.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, ResolvedAlterTableSetOptionsStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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()); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // isIfExists is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsIfExists(this.getIsIfExists()); } public final ImmutableList getNamePath() { return namePath; } public final ImmutableList getOptionList() { return optionList; } public final boolean getIsIfExists() { return isIfExists; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!DebugStrings.isDefaultValue(isIfExists)) { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } } } /** * This statement: RENAME TO ; * *

is an string identifier, * e.g., "TABLE", "VIEW", "INDEX", "FUNCTION", "TYPE", etc. * is a vector giving the identifier path for the object to * be renamed. * is a vector giving the identifier path for the object to * be renamed to. */ public static final class ResolvedRenameStmt extends ResolvedStatement { private final String objectType; private final ImmutableList oldNamePath; private final ImmutableList newNamePath; protected ResolvedRenameStmt(ResolvedRenameStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); objectType = proto.getObjectType(); oldNamePath = ImmutableList.copyOf(proto.getOldNamePathList()); newNamePath = ImmutableList.copyOf(proto.getNewNamePathList()); } public static final ResolvedRenameStmt deserialize( ResolvedRenameStmtProto proto, DeserializationHelper helper) { return new ResolvedRenameStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RENAME_STMT; } @Override public final String nodeKindString() { return "RenameStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedRenameStmtProto.Builder childBuilder = ResolvedRenameStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRenameStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRenameStmtProto.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, ResolvedRenameStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // objectType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setObjectType(this.getObjectType()); // oldNamePath 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.addAllOldNamePath(this.getOldNamePath()); // newNamePath 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.addAllNewNamePath(this.getNewNamePath()); } public final String getObjectType() { return objectType; } public final ImmutableList getOldNamePath() { return oldNamePath; } public final ImmutableList getNewNamePath() { return newNamePath; } @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("object_type", DebugStrings.toStringImpl(objectType))); } { fields.add(new DebugStringField("old_name_path", DebugStrings.toStringImpl(oldNamePath))); } { fields.add(new DebugStringField("new_name_path", DebugStrings.toStringImpl(newNamePath))); } } } /** * This statement: CREATE [OR REPLACE] ROW ACCESS POLICY [IF NOT EXISTS] * [] ON * [GRANT TO ()] * FILTER USING (); * *

indicates if this was CREATE, CREATE OR REPLACE, or * CREATE IF NOT EXISTS. * is the name of the row access policy to be created or an empty * string. * is a vector giving the identifier path of the target * table. * is a TableScan for the target table, which is used during * resolving and validation. Consumers can use either the table * object inside it or target_name_path to reference the table. * (DEPRECATED) is the list of user principals the policy * should apply to. * is the list of user principals the policy should * apply to, and may include parameters. * is a boolean expression that selects the rows that are being * made visible. * is the string form of the predicate. * *

Only one of or will be populated, * depending on whether or not the FEATURE_PARAMETERS_IN_GRANTEE_LIST * is enabled. The is deprecated, and will be removed * along with the corresponding FEATURE once all engines have migrated to * use the . Once is the only * one, then it should be marked as NOT_IGNORABLE. */ public static final class ResolvedCreateRowAccessPolicyStmt extends ResolvedStatement { private final CreateMode createMode; private final String name; private final ImmutableList targetNamePath; private final ImmutableList granteeList; private final ImmutableList granteeExprList; private final ResolvedTableScan tableScan; private final ResolvedExpr predicate; private final String predicateStr; protected ResolvedCreateRowAccessPolicyStmt(ResolvedCreateRowAccessPolicyStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); createMode = proto.getCreateMode(); name = proto.getName(); targetNamePath = ImmutableList.copyOf(proto.getTargetNamePathList()); granteeList = ImmutableList.copyOf(proto.getGranteeListList()); ImmutableList.Builder granteeExprListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getGranteeExprListList()) { granteeExprListBuilder .add(ResolvedExpr.deserialize(element, helper)); } granteeExprList = granteeExprListBuilder.build(); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } if (proto.hasPredicate()) { predicate = ResolvedExpr.deserialize(proto.getPredicate(), helper); } else { predicate = null; } predicateStr = proto.getPredicateStr(); } public static final ResolvedCreateRowAccessPolicyStmt deserialize( ResolvedCreateRowAccessPolicyStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateRowAccessPolicyStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_ROW_ACCESS_POLICY_STMT; } @Override public final String nodeKindString() { return "CreateRowAccessPolicyStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedCreateRowAccessPolicyStmtProto.Builder childBuilder = ResolvedCreateRowAccessPolicyStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateRowAccessPolicyStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateRowAccessPolicyStmtProto.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, ResolvedCreateRowAccessPolicyStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // createMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setCreateMode(this.getCreateMode()); // 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()); // targetNamePath 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.addAllTargetNamePath(this.getTargetNamePath()); // granteeList 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.addAllGranteeList(this.getGranteeList()); // granteeExprList is a collection of AST nodes. Serialize each of them. ImmutableList granteeExprLists = this.getGranteeExprList(); for (ResolvedExpr element : granteeExprLists) { AnyResolvedExprProto.Builder granteeExprListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, granteeExprListBuilder); proto.addGranteeExprList(granteeExprListBuilder.build()); } // tableScan is an AST node. Call its serialization chain. if (this.getTableScan() != null) { ResolvedTableScanProto.Builder tableScanBuilder = ResolvedTableScanProto.newBuilder(); this.getTableScan().serialize( fileDescriptorSetsBuilder, tableScanBuilder); proto.setTableScan( tableScanBuilder.build()); } // predicate is an AST node. Call its serialization chain. if (this.getPredicate() != null) { AnyResolvedExprProto.Builder predicateBuilder = AnyResolvedExprProto.newBuilder(); this.getPredicate().serialize( fileDescriptorSetsBuilder, predicateBuilder); proto.setPredicate( predicateBuilder.build()); } // predicateStr is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setPredicateStr(this.getPredicateStr()); } public final CreateMode getCreateMode() { return createMode; } public final String getName() { return name; } public final ImmutableList getTargetNamePath() { return targetNamePath; } public final ImmutableList getGranteeList() { return granteeList; } public final ImmutableList getGranteeExprList() { return granteeExprList; } public final ResolvedTableScan getTableScan() { return tableScan; } public final ResolvedExpr getPredicate() { return predicate; } public final String getPredicateStr() { return predicateStr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(granteeExprList); visitor.descend(tableScan); visitor.descend(predicate); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(createMode)) { fields.add(new DebugStringField("create_mode", DebugStrings.toStringImpl(createMode))); } if (!DebugStrings.isDefaultValue(name)) { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } { fields.add(new DebugStringField("target_name_path", DebugStrings.toStringImpl(targetNamePath))); } if (!DebugStrings.isDefaultValue(granteeList)) { fields.add(new DebugStringField("grantee_list", DebugStrings.toStringCommaSeparated(granteeList))); } if (!granteeExprList.isEmpty()) { fields.add(new DebugStringField("grantee_expr_list", granteeExprList)); } if (tableScan != null) { fields.add(new DebugStringField("table_scan", tableScan)); } if (predicate != null) { fields.add(new DebugStringField("predicate", predicate)); } if (!DebugStrings.isDefaultValue(predicateStr)) { fields.add(new DebugStringField("predicate_str", DebugStrings.toStringImpl(predicateStr))); } } } /** * This statement: * DROP ROW ACCESS POLICY ON ; or * DROP ALL ROW [ACCESS] POLICIES ON ; * *

indicates that all policies should be dropped. * silently ignore the "policy does not exist" error. * This is not allowed if is_drop_all is true. * is the name of the row policy to be dropped or an empty string. * is a vector giving the identifier path of the target * table. */ public static final class ResolvedDropRowAccessPolicyStmt extends ResolvedStatement { private final boolean isDropAll; private final boolean isIfExists; private final String name; private final ImmutableList targetNamePath; protected ResolvedDropRowAccessPolicyStmt(ResolvedDropRowAccessPolicyStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); isDropAll = proto.getIsDropAll(); isIfExists = proto.getIsIfExists(); name = proto.getName(); targetNamePath = ImmutableList.copyOf(proto.getTargetNamePathList()); } public static final ResolvedDropRowAccessPolicyStmt deserialize( ResolvedDropRowAccessPolicyStmtProto proto, DeserializationHelper helper) { return new ResolvedDropRowAccessPolicyStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_ROW_ACCESS_POLICY_STMT; } @Override public final String nodeKindString() { return "DropRowAccessPolicyStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedDropRowAccessPolicyStmtProto.Builder childBuilder = ResolvedDropRowAccessPolicyStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropRowAccessPolicyStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropRowAccessPolicyStmtProto.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, ResolvedDropRowAccessPolicyStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // isDropAll is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsDropAll(this.getIsDropAll()); // isIfExists is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsIfExists(this.getIsIfExists()); // 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()); // targetNamePath 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.addAllTargetNamePath(this.getTargetNamePath()); } public final boolean getIsDropAll() { return isDropAll; } public final boolean getIsIfExists() { return isIfExists; } public final String getName() { return name; } public final ImmutableList getTargetNamePath() { return targetNamePath; } @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(isDropAll)) { fields.add(new DebugStringField("is_drop_all", DebugStrings.toStringImpl(isDropAll))); } if (!DebugStrings.isDefaultValue(isIfExists)) { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } if (!DebugStrings.isDefaultValue(name)) { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } { fields.add(new DebugStringField("target_name_path", DebugStrings.toStringImpl(targetNamePath))); } } } /** * GRANT TO action for ALTER ROW ACCESS POLICY statement * *

is the list of grantees, and may include parameters. */ public static final class ResolvedGrantToAction extends ResolvedAlterAction { private final ImmutableList granteeExprList; protected ResolvedGrantToAction(ResolvedGrantToActionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder granteeExprListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getGranteeExprListList()) { granteeExprListBuilder .add(ResolvedExpr.deserialize(element, helper)); } granteeExprList = granteeExprListBuilder.build(); } public static final ResolvedGrantToAction deserialize( ResolvedGrantToActionProto proto, DeserializationHelper helper) { return new ResolvedGrantToAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRANT_TO_ACTION; } @Override public final String nodeKindString() { return "GrantToAction"; } /** * Serializes this node into a {@link AnyResolvedAlterActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterActionProto.Builder builder = AnyResolvedAlterActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterActionProto.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, AnyResolvedAlterActionProto.Builder builder) { builder.clear(); ResolvedGrantToActionProto.Builder childBuilder = ResolvedGrantToActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGrantToActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGrantToActionProto.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, ResolvedGrantToActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // granteeExprList is a collection of AST nodes. Serialize each of them. ImmutableList granteeExprLists = this.getGranteeExprList(); for (ResolvedExpr element : granteeExprLists) { AnyResolvedExprProto.Builder granteeExprListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, granteeExprListBuilder); proto.addGranteeExprList(granteeExprListBuilder.build()); } } public final ImmutableList getGranteeExprList() { return granteeExprList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(granteeExprList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!granteeExprList.isEmpty()) { fields.add(new DebugStringField("grantee_expr_list", granteeExprList)); } } } /** * FILTER USING action for ALTER ROW ACCESS POLICY statement * *

is a boolean expression that selects the rows that are being * made visible. * is the string form of the predicate. */ public static final class ResolvedFilterUsingAction extends ResolvedAlterAction { private final ResolvedExpr predicate; private final String predicateStr; protected ResolvedFilterUsingAction(ResolvedFilterUsingActionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasPredicate()) { predicate = ResolvedExpr.deserialize(proto.getPredicate(), helper); } else { predicate = null; } predicateStr = proto.getPredicateStr(); } public static final ResolvedFilterUsingAction deserialize( ResolvedFilterUsingActionProto proto, DeserializationHelper helper) { return new ResolvedFilterUsingAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FILTER_USING_ACTION; } @Override public final String nodeKindString() { return "FilterUsingAction"; } /** * Serializes this node into a {@link AnyResolvedAlterActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterActionProto.Builder builder = AnyResolvedAlterActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterActionProto.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, AnyResolvedAlterActionProto.Builder builder) { builder.clear(); ResolvedFilterUsingActionProto.Builder childBuilder = ResolvedFilterUsingActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFilterUsingActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedFilterUsingActionProto.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, ResolvedFilterUsingActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // predicate is an AST node. Call its serialization chain. if (this.getPredicate() != null) { AnyResolvedExprProto.Builder predicateBuilder = AnyResolvedExprProto.newBuilder(); this.getPredicate().serialize( fileDescriptorSetsBuilder, predicateBuilder); proto.setPredicate( predicateBuilder.build()); } // predicateStr is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setPredicateStr(this.getPredicateStr()); } public final ResolvedExpr getPredicate() { return predicate; } public final String getPredicateStr() { return predicateStr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(predicate); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (predicate != null) { fields.add(new DebugStringField("predicate", predicate)); } { fields.add(new DebugStringField("predicate_str", DebugStrings.toStringImpl(predicateStr))); } } } /** * REVOKE FROM action for ALTER ROW ACCESS POLICY statement * *

is the list of revokees, and may include parameters. * is a boolean indicating whether it was a REVOKE FROM * ALL statement. */ public static final class ResolvedRevokeFromAction extends ResolvedAlterAction { private final ImmutableList revokeeExprList; private final boolean isRevokeFromAll; protected ResolvedRevokeFromAction(ResolvedRevokeFromActionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder revokeeExprListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getRevokeeExprListList()) { revokeeExprListBuilder .add(ResolvedExpr.deserialize(element, helper)); } revokeeExprList = revokeeExprListBuilder.build(); isRevokeFromAll = proto.getIsRevokeFromAll(); } public static final ResolvedRevokeFromAction deserialize( ResolvedRevokeFromActionProto proto, DeserializationHelper helper) { return new ResolvedRevokeFromAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_REVOKE_FROM_ACTION; } @Override public final String nodeKindString() { return "RevokeFromAction"; } /** * Serializes this node into a {@link AnyResolvedAlterActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterActionProto.Builder builder = AnyResolvedAlterActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterActionProto.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, AnyResolvedAlterActionProto.Builder builder) { builder.clear(); ResolvedRevokeFromActionProto.Builder childBuilder = ResolvedRevokeFromActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRevokeFromActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRevokeFromActionProto.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, ResolvedRevokeFromActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // revokeeExprList is a collection of AST nodes. Serialize each of them. ImmutableList revokeeExprLists = this.getRevokeeExprList(); for (ResolvedExpr element : revokeeExprLists) { AnyResolvedExprProto.Builder revokeeExprListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, revokeeExprListBuilder); proto.addRevokeeExprList(revokeeExprListBuilder.build()); } // isRevokeFromAll is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsRevokeFromAll(this.getIsRevokeFromAll()); } public final ImmutableList getRevokeeExprList() { return revokeeExprList; } public final boolean getIsRevokeFromAll() { return isRevokeFromAll; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(revokeeExprList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!revokeeExprList.isEmpty()) { fields.add(new DebugStringField("revokee_expr_list", revokeeExprList)); } if (!DebugStrings.isDefaultValue(isRevokeFromAll)) { fields.add(new DebugStringField("is_revoke_from_all", DebugStrings.toStringImpl(isRevokeFromAll))); } } } /** * RENAME TO action for ALTER ROW ACCESS POLICY statement * *

is the new name of the row access policy. */ public static final class ResolvedRenameToAction extends ResolvedAlterAction { private final String newName; protected ResolvedRenameToAction(ResolvedRenameToActionProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); newName = proto.getNewName(); } public static final ResolvedRenameToAction deserialize( ResolvedRenameToActionProto proto, DeserializationHelper helper) { return new ResolvedRenameToAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RENAME_TO_ACTION; } @Override public final String nodeKindString() { return "RenameToAction"; } /** * Serializes this node into a {@link AnyResolvedAlterActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterActionProto.Builder builder = AnyResolvedAlterActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterActionProto.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, AnyResolvedAlterActionProto.Builder builder) { builder.clear(); ResolvedRenameToActionProto.Builder childBuilder = ResolvedRenameToActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRenameToActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRenameToActionProto.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, ResolvedRenameToActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // newName is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setNewName(this.getNewName()); } public final String getNewName() { return newName; } @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("new_name", DebugStrings.toStringImpl(newName))); } } } /** * This statement: * ALTER ROW ACCESS POLICY [IF EXISTS] * ON * * *

is the name of the row access policy to be altered, scoped to the * table in the base . * is a TableScan for the target table, which is used during * resolving and validation. Consumers can use either the table * object inside it or base to reference the table. */ public static final class ResolvedAlterRowAccessPolicyStmt extends ResolvedAlterObjectStmt { private final String name; private final ResolvedTableScan tableScan; protected ResolvedAlterRowAccessPolicyStmt(ResolvedAlterRowAccessPolicyStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } } public static final ResolvedAlterRowAccessPolicyStmt deserialize( ResolvedAlterRowAccessPolicyStmtProto proto, DeserializationHelper helper) { return new ResolvedAlterRowAccessPolicyStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_ROW_ACCESS_POLICY_STMT; } @Override public final String nodeKindString() { return "AlterRowAccessPolicyStmt"; } /** * Serializes this node into a {@link AnyResolvedAlterObjectStmtProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterObjectStmtProto.Builder builder = AnyResolvedAlterObjectStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterObjectStmtProto.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, AnyResolvedAlterObjectStmtProto.Builder builder) { builder.clear(); ResolvedAlterRowAccessPolicyStmtProto.Builder childBuilder = ResolvedAlterRowAccessPolicyStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterRowAccessPolicyStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterRowAccessPolicyStmtProto.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, ResolvedAlterRowAccessPolicyStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterObjectStmtProto parent = (ResolvedAlterObjectStmtProto) 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()); // tableScan is an AST node. Call its serialization chain. if (this.getTableScan() != null) { ResolvedTableScanProto.Builder tableScanBuilder = ResolvedTableScanProto.newBuilder(); this.getTableScan().serialize( fileDescriptorSetsBuilder, tableScanBuilder); proto.setTableScan( tableScanBuilder.build()); } } public final String getName() { return name; } public final ResolvedTableScan getTableScan() { return tableScan; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (tableScan != null) { fields.add(new DebugStringField("table_scan", tableScan)); } } } /** * This statement creates a user-defined named constant: * CREATE [OR REPLACE] [TEMP | TEMPORARY | PUBLIC | PRIVATE] CONSTANT * [IF NOT EXISTS] = * *

is the identifier path of the named constants. * is the expression that determines the type and the value of the * named constant. Note that need not be constant. Its value * is bound to the named constant which is then treated as * immutable. can be evaluated at the time this statement is * processed or later (lazy evaluation during query execution). */ public static final class ResolvedCreateConstantStmt extends ResolvedCreateStatement { private final ResolvedExpr expr; protected ResolvedCreateConstantStmt(ResolvedCreateConstantStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } } public static final ResolvedCreateConstantStmt deserialize( ResolvedCreateConstantStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateConstantStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_CONSTANT_STMT; } @Override public final String nodeKindString() { return "CreateConstantStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateStatementProto.Builder builder = AnyResolvedCreateStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder) { builder.clear(); ResolvedCreateConstantStmtProto.Builder childBuilder = ResolvedCreateConstantStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateConstantStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateConstantStmtProto.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, ResolvedCreateConstantStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) 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()); } } 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); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } } } /** * This statement creates a user-defined function: * CREATE [TEMP] FUNCTION [IF NOT EXISTS] () * [RETURNS ] [] [LANGUAGE ] * [AS | AS ( )] [OPTIONS ()] * * is the identifier path of the function. * is true iff RETURNS clause is present. * is the return type for the function, which can be any * valid ZetaSQL type, including ARRAY or STRUCT. It is inferred * from if not explicitly set. * TODO: Deprecate and remove this. The return type is * already specified by the . * The names of the function arguments. * is the FunctionSignature of the created function, with all * options. This can be used to create a Function to load into a * Catalog for future queries. * is true if this is an aggregate function. All arguments * are assumed to be aggregate input arguments that may vary for * every row. * is the programming language used by the function. This field * is set to 'SQL' for SQL functions and otherwise to the language * name specified in the LANGUAGE clause. * is a string literal that contains the function definition. Some * engines may allow this argument to be omitted for certain types * of external functions. This will always be set for SQL functions. * is a list of SQL aggregate functions to * compute prior to computing the final . * See below. * is the resolved SQL expression invoked for the * function. This will be unset for external language functions. For * non-template SQL functions, this is a resolved representation of * the expression in . * has engine-specific directives for modifying functions. * is the declared security mode for the function. Values * include 'INVOKER', 'DEFINER'. * is the declared determinism level of the function. * Values are 'DETERMINISTIC', 'NOT DETERMINISTIC', 'IMMUTABLE', * 'STABLE', 'VOLATILE'. * *

Note that and are both marked as IGNORABLE * because an engine could look at either one (but might not look at both). * An engine must look at one (and cannot ignore both) to be semantically * valid, but there is currently no way to enforce that. * *

For aggregate functions, will be true. * Aggregate functions will only occur if LanguageOptions has * FEATURE_CREATE_AGGREGATE_FUNCTION enabled. * *

Arguments to aggregate functions must have * true or false. * Non-aggregate arguments must be passed constant values only. * *

For SQL aggregate functions, there will be both an * , with aggregate expressions to compute first, * and then a final to compute on the results * of the aggregates. Each aggregate expression is a * ResolvedAggregateFunctionCall, and may reference any input arguments. * Each ResolvedComputedColumn in gives the * aggregate expression a column id. The final can * reference these created aggregate columns, and any input arguments * with =NOT_AGGREGATE. * *

For example, with * CREATE TEMP FUNCTION my_avg(x) = (SUM(x) / COUNT(x)); * we would have an with * agg1#1 := SUM(ResolvedArgumentRef(x)) * agg2#2 := COUNT(ResolvedArgumentRef(x)) * and a * ResolvedColumnRef(agg1#1) / ResolvedColumnRef(agg2#2) * *

For example, with * CREATE FUNCTION scaled_avg(x,y NOT AGGREGATE) = (SUM(x) / COUNT(x) * y); * we would have an with * agg1#1 := SUM(ResolvedArgumentRef(x)) * agg2#2 := COUNT(ResolvedArgumentRef(x)) * and a * ResolvedColumnRef(agg1#1) / ResolvedColumnRef(agg2#2) * ResolvedArgumentRef(y) * *

When resolving a query that calls an aggregate UDF, the query will * have a ResolvedAggregateScan that invokes the UDF function. The engine * should remove the UDF aggregate function from the , and * instead compute the additional aggregates from the * UDF's , and then add an additional Project * to compute the final , which should produce the * value for the original ResolvedAggregateScan's computed column for the * UDF. Some rewrites of the ResolvedColumn references inside the UDF will * be required. TODO If using ResolvedColumns makes this renaming * too complicated, we could switch to use ResolvedArgumentRefs, or * something new. */ public static final class ResolvedCreateFunctionStmt extends ResolvedCreateStatement { private final boolean hasExplicitReturnType; private final Type returnType; private final ImmutableList argumentNameList; private final FunctionSignature signature; private final boolean isAggregate; private final String language; private final String code; private final ImmutableList aggregateExpressionList; private final ResolvedExpr functionExpression; private final ImmutableList optionList; private final SqlSecurity sqlSecurity; private final DeterminismLevel determinismLevel; protected ResolvedCreateFunctionStmt(ResolvedCreateFunctionStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); hasExplicitReturnType = proto.getHasExplicitReturnType(); returnType = helper.deserialize(proto.getReturnType()); argumentNameList = ImmutableList.copyOf(proto.getArgumentNameListList()); signature = helper.deserialize(proto.getSignature()); isAggregate = proto.getIsAggregate(); language = proto.getLanguage(); code = proto.getCode(); ImmutableList.Builder aggregateExpressionListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getAggregateExpressionListList()) { aggregateExpressionListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } aggregateExpressionList = aggregateExpressionListBuilder.build(); if (proto.hasFunctionExpression()) { functionExpression = ResolvedExpr.deserialize(proto.getFunctionExpression(), helper); } else { functionExpression = null; } ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); sqlSecurity = proto.getSqlSecurity(); determinismLevel = proto.getDeterminismLevel(); } public static final ResolvedCreateFunctionStmt deserialize( ResolvedCreateFunctionStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateFunctionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_FUNCTION_STMT; } @Override public final String nodeKindString() { return "CreateFunctionStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateStatementProto.Builder builder = AnyResolvedCreateStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder) { builder.clear(); ResolvedCreateFunctionStmtProto.Builder childBuilder = ResolvedCreateFunctionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateFunctionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateFunctionStmtProto.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, ResolvedCreateFunctionStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // hasExplicitReturnType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setHasExplicitReturnType(this.getHasExplicitReturnType()); // returnType is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getReturnType() != null) { proto.setReturnType( ResolvedNodes.serialize(this.getReturnType(), fileDescriptorSetsBuilder)); } // argumentNameList 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.addAllArgumentNameList(this.getArgumentNameList()); // 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)); } // isAggregate is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsAggregate(this.getIsAggregate()); // language is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setLanguage(this.getLanguage()); // code is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setCode(this.getCode()); // aggregateExpressionList is a collection of AST nodes. Serialize each of them. ImmutableList aggregateExpressionLists = this.getAggregateExpressionList(); for (ResolvedComputedColumn element : aggregateExpressionLists) { ResolvedComputedColumnProto.Builder aggregateExpressionListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, aggregateExpressionListBuilder); proto.addAggregateExpressionList(aggregateExpressionListBuilder.build()); } // functionExpression is an AST node. Call its serialization chain. if (this.getFunctionExpression() != null) { AnyResolvedExprProto.Builder functionExpressionBuilder = AnyResolvedExprProto.newBuilder(); this.getFunctionExpression().serialize( fileDescriptorSetsBuilder, functionExpressionBuilder); proto.setFunctionExpression( functionExpressionBuilder.build()); } // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // sqlSecurity is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setSqlSecurity(this.getSqlSecurity()); // determinismLevel is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setDeterminismLevel(this.getDeterminismLevel()); } public final boolean getHasExplicitReturnType() { return hasExplicitReturnType; } public final Type getReturnType() { return returnType; } public final ImmutableList getArgumentNameList() { return argumentNameList; } public final FunctionSignature getSignature() { return signature; } public final boolean getIsAggregate() { return isAggregate; } public final String getLanguage() { return language; } public final String getCode() { return code; } public final ImmutableList getAggregateExpressionList() { return aggregateExpressionList; } public final ResolvedExpr getFunctionExpression() { return functionExpression; } public final ImmutableList getOptionList() { return optionList; } public final SqlSecurity getSqlSecurity() { return sqlSecurity; } public final DeterminismLevel getDeterminismLevel() { return determinismLevel; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(aggregateExpressionList); visitor.descend(functionExpression); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(hasExplicitReturnType)) { fields.add(new DebugStringField("has_explicit_return_type", DebugStrings.toStringImpl(hasExplicitReturnType))); } if (!DebugStrings.isDefaultValue(returnType)) { fields.add(new DebugStringField("return_type", DebugStrings.toStringImpl(returnType))); } if (!DebugStrings.isDefaultValue(argumentNameList)) { fields.add(new DebugStringField("argument_name_list", DebugStrings.toStringCommaSeparated(argumentNameList))); } if (!DebugStrings.isDefaultValue(signature)) { fields.add(new DebugStringField("signature", DebugStrings.toStringVerbose(signature))); } if (!DebugStrings.isDefaultValue(isAggregate)) { fields.add(new DebugStringField("is_aggregate", DebugStrings.toStringImpl(isAggregate))); } if (!DebugStrings.isDefaultValue(language)) { fields.add(new DebugStringField("language", DebugStrings.toStringImpl(language))); } if (!DebugStrings.isDefaultValue(code)) { fields.add(new DebugStringField("code", DebugStrings.toStringImpl(code))); } if (!aggregateExpressionList.isEmpty()) { fields.add(new DebugStringField("aggregate_expression_list", aggregateExpressionList)); } if (functionExpression != null) { fields.add(new DebugStringField("function_expression", functionExpression)); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!DebugStrings.isDefaultValue(sqlSecurity)) { fields.add(new DebugStringField("sql_security", DebugStrings.toStringImpl(sqlSecurity))); } if (!DebugStrings.isDefaultValue(determinismLevel)) { fields.add(new DebugStringField("determinism_level", DebugStrings.toStringImpl(determinismLevel))); } } } /** * This represents an argument definition, e.g. in a function's argument * list. * *

is the name of the argument; optional for DROP FUNCTION statements. * is the type of the argument. * indicates what kind of argument this is, including scalar * vs aggregate. NOT_AGGREGATE means this is a non-aggregate * argument in an aggregate function, which can only passed constant * values only. * *

NOTE: Statements that create functions now include a FunctionSignature * directly, and an argument_name_list if applicable. These completely * describe the function signature, so the ResolvedArgumentDef list can * be considered unnecessary and deprecated. * TODO We could remove this node in the future. */ public static final class ResolvedArgumentDef extends ResolvedArgument { private final String name; private final Type type; private final ArgumentKind argumentKind; protected ResolvedArgumentDef(ResolvedArgumentDefProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); type = helper.deserialize(proto.getType()); argumentKind = proto.getArgumentKind(); } public static final ResolvedArgumentDef deserialize( ResolvedArgumentDefProto proto, DeserializationHelper helper) { return new ResolvedArgumentDef(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ARGUMENT_DEF; } @Override public final String nodeKindString() { return "ArgumentDef"; } /** * 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(); ResolvedArgumentDefProto.Builder childBuilder = ResolvedArgumentDefProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedArgumentDefNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedArgumentDefProto.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, ResolvedArgumentDefProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) 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()); // 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)); } // argumentKind is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setArgumentKind(this.getArgumentKind()); } public final String getName() { return name; } public final Type getType() { return type; } public final ArgumentKind getArgumentKind() { return argumentKind; } @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))); } { fields.add(new DebugStringField("type", DebugStrings.toStringImpl(type))); } if (!DebugStrings.isDefaultValue(argumentKind)) { fields.add(new DebugStringField("argument_kind", DebugStrings.toStringImpl(argumentKind))); } } } /** * This represents an argument reference, e.g. in a function's body. * is the name of the argument. * is the ArgumentKind from the ResolvedArgumentDef. * For scalar functions, this is always SCALAR. * For aggregate functions, it can be AGGREGATE or NOT_AGGREGATE. * If NOT_AGGREGATE, then this is a non-aggregate argument * to an aggregate function, which has one constant value * for the entire function call (over all rows in all groups). * (This is copied from the ResolvedArgumentDef for convenience.) */ public static final class ResolvedArgumentRef extends ResolvedExpr { private final String name; private final ArgumentKind argumentKind; protected ResolvedArgumentRef(ResolvedArgumentRefProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); argumentKind = proto.getArgumentKind(); } public static final ResolvedArgumentRef deserialize( ResolvedArgumentRefProto proto, DeserializationHelper helper) { return new ResolvedArgumentRef(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ARGUMENT_REF; } @Override public final String nodeKindString() { return "ArgumentRef"; } /** * 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(); ResolvedArgumentRefProto.Builder childBuilder = ResolvedArgumentRefProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedArgumentRefNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedArgumentRefProto.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, ResolvedArgumentRefProto.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()); // argumentKind is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setArgumentKind(this.getArgumentKind()); } public final String getName() { return name; } public final ArgumentKind getArgumentKind() { return argumentKind; } @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))); } if (!DebugStrings.isDefaultValue(argumentKind)) { fields.add(new DebugStringField("argument_kind", DebugStrings.toStringImpl(argumentKind))); } } } /** * This statement creates a user-defined table-valued function: * CREATE [TEMP] TABLE FUNCTION [IF NOT EXISTS] * () * [RETURNS ] * [OPTIONS ()] * [LANGUAGE ] * [AS | AS ( )] * * contains the names of the function arguments. * is the FunctionSignature of the created function, with all * options. This can be used to create a Function to load into a * Catalog for future queries. * has engine-specific directives for modifying functions. * is the programming language used by the function. This field * is set to 'SQL' for SQL functions, to the language name specified * in the LANGUAGE clause if present, and to 'UNDECLARED' if both * the LANGUAGE clause and query are not present. * is an optional string literal that contains the function * definition. Some engines may allow this argument to be omitted * for certain types of external functions. This will always be set * for SQL functions. * is the SQL query invoked for the function. This will be unset * for external language functions. For non-templated SQL functions, * this is a resolved representation of the query in . * is the list of resolved output * columns returned by the table-valued function. * If true, this function returns a value table. * Rather than producing rows with named columns, it produces * rows with a single unnamed value type. will * have exactly one anonymous column (with no name). * See (broken link). * is the declared security mode for the function. Values * include 'INVOKER', 'DEFINER'. * *

---------------------- * Table-Valued Functions * ---------------------- * *

This is a statement to create a new table-valued function. Each * table-valued function returns an entire table as output instead of a * single scalar value. Table-valued functions can only be created if * LanguageOptions has FEATURE_CREATE_TABLE_FUNCTION enabled. * *

For SQL table-valued functions that include a defined SQL body, the * is non-NULL and contains the resolved SQL body. * In this case, contains a list of the * output columns of the SQL body. The uses * ResolvedArgumentRefs to refer to scalar arguments and * ResolvedRelationArgumentScans to refer to relation arguments. * *

The table-valued function may include RETURNS TABLE<...> to explicitly * specify a schema for the output table returned by the function. If the * function declaration includes a SQL body, then the names and types of the * output columns of the corresponding will have been * coerced to exactly match 1:1 with the names and types of the columns * specified in the RETURNS TABLE<...> section. * *

When resolving a query that calls a table-valued function, the query will * have a ResolvedTVFScan that invokes the function. * *

Value tables: If the function declaration includes a value-table * parameter, this is written as an argument of type "TABLE" where the table * contains a single anonymous column with a type but no name. In this case, * calls to the function may pass a (regular or value) table with a single * (named or unnamed) column for any of these parameters, and ZetaSQL * accepts these arguments as long as the column type matches. * *

Similarly, if the CREATE TABLE FUNCTION statement includes a "RETURNS * TABLE" section with a single column with no name, then this defines a * value-table return type. The function then returns a value table as long * as the SQL body returns a single column whose type matches (independent of * whether the SQL body result is a value table or not, and whether the * returned column is named or unnamed). * *

-------------------------------- * Templated Table-Valued Functions * -------------------------------- * *

ZetaSQL supports table-valued function declarations with parameters of * type ANY TABLE. This type indicates that any schema is valid for tables * passed for this parameter. In this case: * *

* the IsTemplated() method of the field returns true, * * the field is empty, * * the field is set to a default value of false (since * ZetaSQL cannot analyze the function body in the presence of templated * parameters, it is not possible to detect this property yet), * *

TODO: Update this description once ZetaSQL supports more types * of templated function parameters. Currently only ANY TABLE is supported. */ public static final class ResolvedCreateTableFunctionStmt extends ResolvedCreateStatement { private final ImmutableList argumentNameList; private final FunctionSignature signature; private final ImmutableList optionList; private final String language; private final String code; private final ResolvedScan query; private final ImmutableList outputColumnList; private final boolean isValueTable; private final SqlSecurity sqlSecurity; protected ResolvedCreateTableFunctionStmt(ResolvedCreateTableFunctionStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); argumentNameList = ImmutableList.copyOf(proto.getArgumentNameListList()); signature = helper.deserialize(proto.getSignature()); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); language = proto.getLanguage(); code = proto.getCode(); if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } ImmutableList.Builder outputColumnListBuilder = ImmutableList.builder(); for (ResolvedOutputColumnProto element : proto.getOutputColumnListList()) { outputColumnListBuilder .add(ResolvedOutputColumn.deserialize(element, helper)); } outputColumnList = outputColumnListBuilder.build(); isValueTable = proto.getIsValueTable(); sqlSecurity = proto.getSqlSecurity(); } public static final ResolvedCreateTableFunctionStmt deserialize( ResolvedCreateTableFunctionStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateTableFunctionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_TABLE_FUNCTION_STMT; } @Override public final String nodeKindString() { return "CreateTableFunctionStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateStatementProto.Builder builder = AnyResolvedCreateStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder) { builder.clear(); ResolvedCreateTableFunctionStmtProto.Builder childBuilder = ResolvedCreateTableFunctionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateTableFunctionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateTableFunctionStmtProto.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, ResolvedCreateTableFunctionStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // argumentNameList 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.addAllArgumentNameList(this.getArgumentNameList()); // 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)); } // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // language is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setLanguage(this.getLanguage()); // code is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setCode(this.getCode()); // query is an AST node. Call its serialization chain. if (this.getQuery() != null) { AnyResolvedScanProto.Builder queryBuilder = AnyResolvedScanProto.newBuilder(); this.getQuery().serialize( fileDescriptorSetsBuilder, queryBuilder); proto.setQuery( queryBuilder.build()); } // outputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList outputColumnLists = this.getOutputColumnList(); for (ResolvedOutputColumn element : outputColumnLists) { ResolvedOutputColumnProto.Builder outputColumnListBuilder = ResolvedOutputColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, outputColumnListBuilder); proto.addOutputColumnList(outputColumnListBuilder.build()); } // isValueTable is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsValueTable(this.getIsValueTable()); // sqlSecurity is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setSqlSecurity(this.getSqlSecurity()); } public final ImmutableList getArgumentNameList() { return argumentNameList; } public final FunctionSignature getSignature() { return signature; } public final ImmutableList getOptionList() { return optionList; } public final String getLanguage() { return language; } public final String getCode() { return code; } public final ResolvedScan getQuery() { return query; } public final ImmutableList getOutputColumnList() { return outputColumnList; } public final boolean getIsValueTable() { return isValueTable; } public final SqlSecurity getSqlSecurity() { return sqlSecurity; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(query); visitor.descend(outputColumnList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(argumentNameList)) { fields.add(new DebugStringField("argument_name_list", DebugStrings.toStringCommaSeparated(argumentNameList))); } if (!DebugStrings.isDefaultValue(signature)) { fields.add(new DebugStringField("signature", DebugStrings.toStringVerbose(signature))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!DebugStrings.isDefaultValue(language)) { fields.add(new DebugStringField("language", DebugStrings.toStringImpl(language))); } if (!DebugStrings.isDefaultValue(code)) { fields.add(new DebugStringField("code", DebugStrings.toStringImpl(code))); } if (query != null) { fields.add(new DebugStringField("query", query)); } if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } if (!DebugStrings.isDefaultValue(isValueTable)) { fields.add(new DebugStringField("is_value_table", DebugStrings.toStringImpl(isValueTable))); } if (!DebugStrings.isDefaultValue(sqlSecurity)) { fields.add(new DebugStringField("sql_security", DebugStrings.toStringImpl(sqlSecurity))); } } } /** * This represents a relation argument reference in a table-valued function's * body. The 'column_list' of this ResolvedScan includes column names from * the relation argument in the table-valued function signature. */ public static final class ResolvedRelationArgumentScan extends ResolvedScan { /** * This is the name of the relation argument for the table-valued * function. It is used to match this relation argument reference in * a TVF SQL function body with one of possibly several relation * arguments in the TVF call. */ private final String name; /** * If true, the result of this query is a value table. Rather than * producing rows with named columns, it produces rows with a single * unnamed value type. See (broken link). */ private final boolean isValueTable; protected ResolvedRelationArgumentScan(ResolvedRelationArgumentScanProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); isValueTable = proto.getIsValueTable(); } public static final ResolvedRelationArgumentScan deserialize( ResolvedRelationArgumentScanProto proto, DeserializationHelper helper) { return new ResolvedRelationArgumentScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RELATION_ARGUMENT_SCAN; } @Override public final String nodeKindString() { return "RelationArgumentScan"; } /** * 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(); ResolvedRelationArgumentScanProto.Builder childBuilder = ResolvedRelationArgumentScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRelationArgumentScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRelationArgumentScanProto.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, ResolvedRelationArgumentScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) 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()); // isValueTable is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsValueTable(this.getIsValueTable()); } /** * This is the name of the relation argument for the table-valued * function. It is used to match this relation argument reference in * a TVF SQL function body with one of possibly several relation * arguments in the TVF call. */ public final String getName() { return name; } /** * If true, the result of this query is a value table. Rather than * producing rows with named columns, it produces rows with a single * unnamed value type. See (broken link). */ public final boolean getIsValueTable() { return isValueTable; } @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))); } if (!DebugStrings.isDefaultValue(isValueTable)) { fields.add(new DebugStringField("is_value_table", DebugStrings.toStringImpl(isValueTable))); } } } /** * This statement: [ () ]; * *

is an optional list of parameters. If given, each parameter * may consist of a type, or a name and a type. * *

NOTE: This can be considered deprecated in favor of the FunctionSignature * stored directly in the statement. * *

NOTE: ResolvedArgumentList is not related to the ResolvedArgument class, * which just exists to organize node classes. */ public static final class ResolvedArgumentList extends ResolvedArgument { private final ImmutableList argList; protected ResolvedArgumentList(ResolvedArgumentListProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder argListBuilder = ImmutableList.builder(); for (ResolvedArgumentDefProto element : proto.getArgListList()) { argListBuilder .add(ResolvedArgumentDef.deserialize(element, helper)); } argList = argListBuilder.build(); } public static final ResolvedArgumentList deserialize( ResolvedArgumentListProto proto, DeserializationHelper helper) { return new ResolvedArgumentList(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ARGUMENT_LIST; } @Override public final String nodeKindString() { return "ArgumentList"; } /** * 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(); ResolvedArgumentListProto.Builder childBuilder = ResolvedArgumentListProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedArgumentListNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedArgumentListProto.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, ResolvedArgumentListProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // argList is a collection of AST nodes. Serialize each of them. ImmutableList argLists = this.getArgList(); for (ResolvedArgumentDef element : argLists) { ResolvedArgumentDefProto.Builder argListBuilder = ResolvedArgumentDefProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, argListBuilder); proto.addArgList(argListBuilder.build()); } } public final ImmutableList getArgList() { return argList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(argList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!argList.isEmpty()) { fields.add(new DebugStringField("arg_list", argList)); } } } /** * This wrapper is used for an optional FunctionSignature. */ public static final class ResolvedFunctionSignatureHolder extends ResolvedArgument { private final FunctionSignature signature; protected ResolvedFunctionSignatureHolder(ResolvedFunctionSignatureHolderProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); signature = helper.deserialize(proto.getSignature()); } public static final ResolvedFunctionSignatureHolder deserialize( ResolvedFunctionSignatureHolderProto proto, DeserializationHelper helper) { return new ResolvedFunctionSignatureHolder(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FUNCTION_SIGNATURE_HOLDER; } @Override public final String nodeKindString() { return "FunctionSignatureHolder"; } /** * 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(); ResolvedFunctionSignatureHolderProto.Builder childBuilder = ResolvedFunctionSignatureHolderProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFunctionSignatureHolderNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedFunctionSignatureHolderProto.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, ResolvedFunctionSignatureHolderProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // 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)); } } public final FunctionSignature getSignature() { return signature; } @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("signature", DebugStrings.toStringVerbose(signature))); } } } /** * This statement: DROP FUNCTION [IF EXISTS] * [ () ]; * *

silently ignore the "name_path does not exist" error. * is the identifier path of the function to be dropped. * is an optional list of parameters. If given, each parameter * may consist of a type, or a name and a type. The name is * disregarded, and is allowed to permit copy-paste from CREATE * FUNCTION statements. * is the signature of the dropped function. Argument names and * argument options are ignored because only the types matter * for matching signatures in DROP FUNCTION. The return type * in this signature will always be , since return type * is ignored when matching signatures for DROP. * TODO could be deprecated in favor of this. */ public static final class ResolvedDropFunctionStmt extends ResolvedStatement { private final boolean isIfExists; private final ImmutableList namePath; /** * NOTE: arguments for DROP FUNCTION statements are matched only on * type; names for any arguments in ResolvedArgumentList will be set * to the empty string irrespective of whether or not argument names * were given in the DROP FUNCTION statement. */ private final ResolvedArgumentList arguments; /** * NOTE: arguments for DROP FUNCTION statements are matched only on * type; names are irrelevant, so no argument names are saved to use * with this signature. Additionally, the return type will always be * , since return types are ignored for DROP FUNCTION. */ private final ResolvedFunctionSignatureHolder signature; protected ResolvedDropFunctionStmt(ResolvedDropFunctionStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); namePath = ImmutableList.copyOf(proto.getNamePathList()); if (proto.hasArguments()) { arguments = ResolvedArgumentList.deserialize(proto.getArguments(), helper); } else { arguments = null; } if (proto.hasSignature()) { signature = ResolvedFunctionSignatureHolder.deserialize(proto.getSignature(), helper); } else { signature = null; } } public static final ResolvedDropFunctionStmt deserialize( ResolvedDropFunctionStmtProto proto, DeserializationHelper helper) { return new ResolvedDropFunctionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_FUNCTION_STMT; } @Override public final String nodeKindString() { return "DropFunctionStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedDropFunctionStmtProto.Builder childBuilder = ResolvedDropFunctionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropFunctionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropFunctionStmtProto.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, ResolvedDropFunctionStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // isIfExists is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsIfExists(this.getIsIfExists()); // 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()); // arguments is an AST node. Call its serialization chain. if (this.getArguments() != null) { ResolvedArgumentListProto.Builder argumentsBuilder = ResolvedArgumentListProto.newBuilder(); this.getArguments().serialize( fileDescriptorSetsBuilder, argumentsBuilder); proto.setArguments( argumentsBuilder.build()); } // signature is an AST node. Call its serialization chain. if (this.getSignature() != null) { ResolvedFunctionSignatureHolderProto.Builder signatureBuilder = ResolvedFunctionSignatureHolderProto.newBuilder(); this.getSignature().serialize( fileDescriptorSetsBuilder, signatureBuilder); proto.setSignature( signatureBuilder.build()); } } public final boolean getIsIfExists() { return isIfExists; } public final ImmutableList getNamePath() { return namePath; } /** * NOTE: arguments for DROP FUNCTION statements are matched only on * type; names for any arguments in ResolvedArgumentList will be set * to the empty string irrespective of whether or not argument names * were given in the DROP FUNCTION statement. */ public final ResolvedArgumentList getArguments() { return arguments; } /** * NOTE: arguments for DROP FUNCTION statements are matched only on * type; names are irrelevant, so no argument names are saved to use * with this signature. Additionally, the return type will always be * , since return types are ignored for DROP FUNCTION. */ public final ResolvedFunctionSignatureHolder getSignature() { return signature; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(arguments); visitor.descend(signature); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (arguments != null) { fields.add(new DebugStringField("arguments", arguments)); } if (signature != null) { fields.add(new DebugStringField("signature", signature)); } } } /** * This statement: CALL ; * *

Procedure to call. * Resolved FunctionSignature for this procedure. * Procedure arguments. */ public static final class ResolvedCallStmt extends ResolvedStatement { private final Procedure procedure; private final FunctionSignature signature; private final ImmutableList argumentList; protected ResolvedCallStmt(ResolvedCallStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); procedure = helper.deserialize(proto.getProcedure()); signature = helper.deserialize(proto.getSignature()); ImmutableList.Builder argumentListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getArgumentListList()) { argumentListBuilder .add(ResolvedExpr.deserialize(element, helper)); } argumentList = argumentListBuilder.build(); } public static final ResolvedCallStmt deserialize( ResolvedCallStmtProto proto, DeserializationHelper helper) { return new ResolvedCallStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CALL_STMT; } @Override public final String nodeKindString() { return "CallStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedCallStmtProto.Builder childBuilder = ResolvedCallStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCallStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCallStmtProto.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, ResolvedCallStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // procedure is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getProcedure() != null) { proto.setProcedure( ResolvedNodes.serialize(this.getProcedure(), 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()); } } public final Procedure getProcedure() { return procedure; } public final FunctionSignature getSignature() { return signature; } public final ImmutableList getArgumentList() { return argumentList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(argumentList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("procedure", DebugStrings.toStringImpl(procedure))); } if (!DebugStrings.isDefaultValue(signature)) { fields.add(new DebugStringField("signature", DebugStrings.toStringImpl(signature))); } if (!argumentList.isEmpty()) { fields.add(new DebugStringField("argument_list", argumentList)); } } } /** * This statement: IMPORT * [ [AS|INTO ] * |] * []; * *

The type of the object, currently supports MODULE and PROTO. * The identifier path of the object to import, e.g., foo.bar, * used in IMPORT MODULE statement. * The file path of the object to import, e.g., "file.proto", * used in IMPORT PROTO statement. * The AS alias path for the object. * The INTO alias path for the object. * Engine-specific directives for the import. * *

Either or will be populated but not both. * will be populated for IMPORT MODULE. * will be populated for IMPORT PROTO. * *

At most one of or will be populated. * may be populated for IMPORT MODULE. * may be populated for IMPORT PROTO. * *

IMPORT MODULE and IMPORT PROTO both support options. * *

See (broken link) for more detail on IMPORT MODULE. * See (broken link) for more detail on IMPORT PROTO. */ public static final class ResolvedImportStmt extends ResolvedStatement { private final ImportKind importKind; private final ImmutableList namePath; private final String filePath; private final ImmutableList aliasPath; private final ImmutableList intoAliasPath; private final ImmutableList optionList; protected ResolvedImportStmt(ResolvedImportStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); importKind = proto.getImportKind(); namePath = ImmutableList.copyOf(proto.getNamePathList()); filePath = proto.getFilePath(); aliasPath = ImmutableList.copyOf(proto.getAliasPathList()); intoAliasPath = ImmutableList.copyOf(proto.getIntoAliasPathList()); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } public static final ResolvedImportStmt deserialize( ResolvedImportStmtProto proto, DeserializationHelper helper) { return new ResolvedImportStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_IMPORT_STMT; } @Override public final String nodeKindString() { return "ImportStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedImportStmtProto.Builder childBuilder = ResolvedImportStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedImportStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedImportStmtProto.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, ResolvedImportStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // importKind is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setImportKind(this.getImportKind()); // 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()); // filePath is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setFilePath(this.getFilePath()); // aliasPath 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.addAllAliasPath(this.getAliasPath()); // intoAliasPath 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.addAllIntoAliasPath(this.getIntoAliasPath()); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } } public final ImportKind getImportKind() { return importKind; } public final ImmutableList getNamePath() { return namePath; } public final String getFilePath() { return filePath; } public final ImmutableList getAliasPath() { return aliasPath; } public final ImmutableList getIntoAliasPath() { return intoAliasPath; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("import_kind", DebugStrings.toStringImpl(importKind))); } if (!DebugStrings.isDefaultValue(namePath)) { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!DebugStrings.isDefaultValue(filePath)) { fields.add(new DebugStringField("file_path", DebugStrings.toStringImpl(filePath))); } if (!DebugStrings.isDefaultValue(aliasPath)) { fields.add(new DebugStringField("alias_path", DebugStrings.toStringImpl(aliasPath))); } if (!DebugStrings.isDefaultValue(intoAliasPath)) { fields.add(new DebugStringField("into_alias_path", DebugStrings.toStringImpl(intoAliasPath))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This statement: MODULE []; * *

is the identifier path of the module. * Engine-specific directives for the module statement. * *

See (broken link) for more detail on MODULEs. */ public static final class ResolvedModuleStmt extends ResolvedStatement { private final ImmutableList namePath; private final ImmutableList optionList; protected ResolvedModuleStmt(ResolvedModuleStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } public static final ResolvedModuleStmt deserialize( ResolvedModuleStmtProto proto, DeserializationHelper helper) { return new ResolvedModuleStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MODULE_STMT; } @Override public final String nodeKindString() { return "ModuleStmt"; } /** * Serializes this node into a {@link AnyResolvedStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedStatementProto.Builder builder = AnyResolvedStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedStatementProto.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, AnyResolvedStatementProto.Builder builder) { builder.clear(); ResolvedModuleStmtProto.Builder childBuilder = ResolvedModuleStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedModuleStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedModuleStmtProto.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, ResolvedModuleStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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()); // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } } public final ImmutableList getNamePath() { return namePath; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This represents a HAVING MAX or HAVING MIN modifier in an aggregate * expression. If an aggregate has arguments (x HAVING {MAX/MIN} y), * the aggregate will be computed over only the x values in the rows with the * maximal/minimal values of y. * *

the MAX/MIN kind of this HAVING * the HAVING expression (y in the above example) */ public static final class ResolvedAggregateHavingModifier extends ResolvedArgument { private final HavingModifierKind kind; private final ResolvedExpr havingExpr; protected ResolvedAggregateHavingModifier(ResolvedAggregateHavingModifierProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); kind = proto.getKind(); if (proto.hasHavingExpr()) { havingExpr = ResolvedExpr.deserialize(proto.getHavingExpr(), helper); } else { havingExpr = null; } } public static final ResolvedAggregateHavingModifier deserialize( ResolvedAggregateHavingModifierProto proto, DeserializationHelper helper) { return new ResolvedAggregateHavingModifier(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_AGGREGATE_HAVING_MODIFIER; } @Override public final String nodeKindString() { return "AggregateHavingModifier"; } /** * 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(); ResolvedAggregateHavingModifierProto.Builder childBuilder = ResolvedAggregateHavingModifierProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAggregateHavingModifierNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAggregateHavingModifierProto.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, ResolvedAggregateHavingModifierProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // kind is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setKind(this.getKind()); // havingExpr is an AST node. Call its serialization chain. if (this.getHavingExpr() != null) { AnyResolvedExprProto.Builder havingExprBuilder = AnyResolvedExprProto.newBuilder(); this.getHavingExpr().serialize( fileDescriptorSetsBuilder, havingExprBuilder); proto.setHavingExpr( havingExprBuilder.build()); } } public final HavingModifierKind getKind() { return kind; } public final ResolvedExpr getHavingExpr() { return havingExpr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(havingExpr); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("kind", DebugStrings.toStringImpl(kind))); } if (havingExpr != null) { fields.add(new DebugStringField("having_expr", havingExpr)); } } } /** * This statement: * CREATE MATERIALIZED VIEW [PARTITION BY expr, ...] * [CLUSTER BY expr, ...] [OPTIONS (...)] AS SELECT ... * *

matches 1:1 with the in * ResolvedCreateViewBase and provides explicit definition for each * ResolvedColumn produced by . Output column names and types must * match column definition names and types. If the table is a value table, * must have exactly one column, with a generated * name such as "$struct". * *

Currently contains the same schema information * (column names and types) as , but when/if we * allow specifying column OPTIONS as part of CMV statement, this information * will be available only in . Therefore, consumers * are encouraged to read from rather than from * to determine the schema, if possible. * *

specifies the partitioning expressions for the * materialized view. * specifies the clustering expressions for the * materialized view. */ public static final class ResolvedCreateMaterializedViewStmt extends ResolvedCreateViewBase { private final ImmutableList columnDefinitionList; private final ImmutableList partitionByList; private final ImmutableList clusterByList; protected ResolvedCreateMaterializedViewStmt(ResolvedCreateMaterializedViewStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder columnDefinitionListBuilder = ImmutableList.builder(); for (ResolvedColumnDefinitionProto element : proto.getColumnDefinitionListList()) { columnDefinitionListBuilder .add(ResolvedColumnDefinition.deserialize(element, helper)); } columnDefinitionList = columnDefinitionListBuilder.build(); ImmutableList.Builder partitionByListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getPartitionByListList()) { partitionByListBuilder .add(ResolvedExpr.deserialize(element, helper)); } partitionByList = partitionByListBuilder.build(); ImmutableList.Builder clusterByListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getClusterByListList()) { clusterByListBuilder .add(ResolvedExpr.deserialize(element, helper)); } clusterByList = clusterByListBuilder.build(); } public static final ResolvedCreateMaterializedViewStmt deserialize( ResolvedCreateMaterializedViewStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateMaterializedViewStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_MATERIALIZED_VIEW_STMT; } @Override public final String nodeKindString() { return "CreateMaterializedViewStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateViewBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateViewBaseProto.Builder builder = AnyResolvedCreateViewBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateViewBaseProto.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, AnyResolvedCreateViewBaseProto.Builder builder) { builder.clear(); ResolvedCreateMaterializedViewStmtProto.Builder childBuilder = ResolvedCreateMaterializedViewStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateMaterializedViewStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateMaterializedViewStmtProto.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, ResolvedCreateMaterializedViewStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateViewBaseProto parent = (ResolvedCreateViewBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // columnDefinitionList is a collection of AST nodes. Serialize each of them. ImmutableList columnDefinitionLists = this.getColumnDefinitionList(); for (ResolvedColumnDefinition element : columnDefinitionLists) { ResolvedColumnDefinitionProto.Builder columnDefinitionListBuilder = ResolvedColumnDefinitionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, columnDefinitionListBuilder); proto.addColumnDefinitionList(columnDefinitionListBuilder.build()); } // partitionByList is a collection of AST nodes. Serialize each of them. ImmutableList partitionByLists = this.getPartitionByList(); for (ResolvedExpr element : partitionByLists) { AnyResolvedExprProto.Builder partitionByListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, partitionByListBuilder); proto.addPartitionByList(partitionByListBuilder.build()); } // clusterByList is a collection of AST nodes. Serialize each of them. ImmutableList clusterByLists = this.getClusterByList(); for (ResolvedExpr element : clusterByLists) { AnyResolvedExprProto.Builder clusterByListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, clusterByListBuilder); proto.addClusterByList(clusterByListBuilder.build()); } } public final ImmutableList getColumnDefinitionList() { return columnDefinitionList; } public final ImmutableList getPartitionByList() { return partitionByList; } public final ImmutableList getClusterByList() { return clusterByList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnDefinitionList); visitor.descend(partitionByList); visitor.descend(clusterByList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!columnDefinitionList.isEmpty()) { fields.add(new DebugStringField("column_definition_list", columnDefinitionList)); } if (!partitionByList.isEmpty()) { fields.add(new DebugStringField("partition_by_list", partitionByList)); } if (!clusterByList.isEmpty()) { fields.add(new DebugStringField("cluster_by_list", clusterByList)); } } } /** * This statement creates a user-defined procedure: * CREATE [OR REPLACE] [TEMP] PROCEDURE [IF NOT EXISTS] * () [OPTIONS ()] * BEGIN * * END; * *

is the identifier path of the procedure. * The names of the function arguments. * is the FunctionSignature of the created procedure, with all * options. This can be used to create a procedure to load into a * Catalog for future queries. * has engine-specific directives for modifying procedures. * is a string literal that contains the procedure body. * It includes everything from the BEGIN keyword to the END keyword, * inclusive. * * The resolver will perform some basic validation on the procedure * body, for example, verifying that DECLARE statements are in the * proper position, and that variables are not declared more than * once, but any validation that requires the catalog (including * generating resolved tree nodes for individual statements) is * deferred until the procedure is actually called. This deferral * makes it possible to define a procedure which references a table * or routine that does not yet exist, so long as the entity is * created before the procedure is called. */ public static final class ResolvedCreateProcedureStmt extends ResolvedCreateStatement { private final ImmutableList argumentNameList; private final FunctionSignature signature; private final ImmutableList optionList; private final String procedureBody; protected ResolvedCreateProcedureStmt(ResolvedCreateProcedureStmtProto proto, DeserializationHelper helper) { super(proto.getParent(), helper); argumentNameList = ImmutableList.copyOf(proto.getArgumentNameListList()); signature = helper.deserialize(proto.getSignature()); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); procedureBody = proto.getProcedureBody(); } public static final ResolvedCreateProcedureStmt deserialize( ResolvedCreateProcedureStmtProto proto, DeserializationHelper helper) { return new ResolvedCreateProcedureStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_PROCEDURE_STMT; } @Override public final String nodeKindString() { return "CreateProcedureStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateStatementProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateStatementProto.Builder builder = AnyResolvedCreateStatementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateStatementProto.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, AnyResolvedCreateStatementProto.Builder builder) { builder.clear(); ResolvedCreateProcedureStmtProto.Builder childBuilder = ResolvedCreateProcedureStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateProcedureStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateProcedureStmtProto.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, ResolvedCreateProcedureStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // argumentNameList 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.addAllArgumentNameList(this.getArgumentNameList()); // 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)); } // optionList is a collection of AST nodes. Serialize each of them. ImmutableList optionLists = this.getOptionList(); for (ResolvedOption element : optionLists) { ResolvedOptionProto.Builder optionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionListBuilder); proto.addOptionList(optionListBuilder.build()); } // procedureBody is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setProcedureBody(this.getProcedureBody()); } public final ImmutableList getArgumentNameList() { return argumentNameList; } public final FunctionSignature getSignature() { return signature; } public final ImmutableList getOptionList() { return optionList; } public final String getProcedureBody() { return procedureBody; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } protected void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("argument_name_list", DebugStrings.toStringCommaSeparated(argumentNameList))); } { fields.add(new DebugStringField("signature", DebugStrings.toStringVerbose(signature))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } { fields.add(new DebugStringField("procedure_body", DebugStrings.toStringImpl(procedureBody))); } } } }