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

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

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

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

import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
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.Column;
import com.google.zetasql.ColumnRefProto;
import com.google.zetasql.Connection;
import com.google.zetasql.ConnectionRefProto;
import com.google.zetasql.Constant;
import com.google.zetasql.ConstantRefProto;
import com.google.zetasql.FieldDescriptorRefProto;
import com.google.zetasql.FileDescriptorSetsBuilder;
import com.google.zetasql.Function;
import com.google.zetasql.FunctionProtos.TVFArgumentProto;
import com.google.zetasql.ZetaSQLAnnotation.AnnotationMapProto;
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.DescriptorPool.ZetaSQLFieldDescriptor;
import com.google.zetasql.DescriptorPool.ZetaSQLOneofDescriptor;
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.ZetaSQLTypeModifiers.TypeModifiersProto;
import com.google.zetasql.ZetaSQLTypeParameters.TypeParametersProto;
import com.google.zetasql.GraphElementLabel;
import com.google.zetasql.GraphElementLabelRefProto;
import com.google.zetasql.GraphElementTable;
import com.google.zetasql.GraphElementTableRefProto;
import com.google.zetasql.GraphPropertyDeclaration;
import com.google.zetasql.GraphPropertyDeclarationRefProto;
import com.google.zetasql.Model;
import com.google.zetasql.ModelRefProto;
import com.google.zetasql.Procedure;
import com.google.zetasql.ProcedureRefProto;
import com.google.zetasql.PropertyGraph;
import com.google.zetasql.PropertyGraphRefProto;
import com.google.zetasql.ResolvedCollationProto;
import com.google.zetasql.ResolvedColumnProto;
import com.google.zetasql.ResolvedNodeProto;
import com.google.zetasql.Sequence;
import com.google.zetasql.SequenceRefProto;
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.TypeParameters;
import com.google.zetasql.Value;
import com.google.zetasql.ValueWithTypeProto;
import com.google.zetasql.resolvedast.ResolvedColumn;
import com.google.zetasql.resolvedast.ResolvedAggregateHavingModifierEnums.HavingModifierKind;
import com.google.zetasql.resolvedast.ResolvedArgumentDefEnums.ArgumentKind;
import com.google.zetasql.resolvedast.ResolvedAuxLoadDataStmtEnums.InsertionMode;
import com.google.zetasql.resolvedast.ResolvedBeginStmtEnums.ReadWriteMode;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.CreateMode;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.CreateScope;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.DeterminismLevel;
import com.google.zetasql.resolvedast.ResolvedCreateStatementEnums.SqlSecurity;
import com.google.zetasql.resolvedast.ResolvedDropIndexStmtEnums.IndexType;
import com.google.zetasql.resolvedast.ResolvedDropStmtEnums.DropMode;
import com.google.zetasql.resolvedast.ResolvedForeignKeyEnums.ActionOperation;
import com.google.zetasql.resolvedast.ResolvedForeignKeyEnums.MatchMode;
import com.google.zetasql.resolvedast.ResolvedFunctionCallBaseEnums.ErrorMode;
import com.google.zetasql.resolvedast.ResolvedGeneratedColumnInfoEnums.GeneratedMode;
import com.google.zetasql.resolvedast.ResolvedGeneratedColumnInfoEnums.StoredMode;
import com.google.zetasql.resolvedast.ResolvedGraphEdgeScanEnums.EdgeOrientation;
import com.google.zetasql.resolvedast.ResolvedGraphLabelNaryExprEnums.GraphLogicalOpType;
import com.google.zetasql.resolvedast.ResolvedGraphPathModeEnums.PathMode;
import com.google.zetasql.resolvedast.ResolvedGraphPathSearchPrefixEnums.PathSearchPrefixType;
import com.google.zetasql.resolvedast.ResolvedImportStmtEnums.ImportKind;
import com.google.zetasql.resolvedast.ResolvedInsertStmtEnums.InsertMode;
import com.google.zetasql.resolvedast.ResolvedJoinScanEnums.JoinType;
import com.google.zetasql.resolvedast.ResolvedLockModeEnums.LockStrengthType;
import com.google.zetasql.resolvedast.ResolvedMatchRecognizePatternAnchorEnums.Mode;
import com.google.zetasql.resolvedast.ResolvedMatchRecognizePatternOperationEnums.MatchRecognizePatternOperationType;
import com.google.zetasql.resolvedast.ResolvedMatchRecognizeScanEnums.AfterMatchSkipMode;
import com.google.zetasql.resolvedast.ResolvedMergeWhenEnums.ActionType;
import com.google.zetasql.resolvedast.ResolvedMergeWhenEnums.MatchType;
import com.google.zetasql.resolvedast.ResolvedNonScalarFunctionCallBaseEnums.NullHandlingModifier;
import com.google.zetasql.resolvedast.ResolvedOnConflictClauseEnums.ConflictAction;
import com.google.zetasql.resolvedast.ResolvedOptionEnums.AssignmentOp;
import com.google.zetasql.resolvedast.ResolvedOrderByItemEnums.NullOrderMode;
import com.google.zetasql.resolvedast.ResolvedRecursiveScanEnums.RecursiveSetOperationType;
import com.google.zetasql.resolvedast.ResolvedSampleScanEnums.SampleUnit;
import com.google.zetasql.resolvedast.ResolvedSetOperationScanEnums.SetOperationColumnMatchMode;
import com.google.zetasql.resolvedast.ResolvedSetOperationScanEnums.SetOperationColumnPropagationMode;
import com.google.zetasql.resolvedast.ResolvedSetOperationScanEnums.SetOperationType;
import com.google.zetasql.resolvedast.ResolvedStatementEnums.ObjectAccess;
import com.google.zetasql.resolvedast.ResolvedSubqueryExprEnums.SubqueryType;
import com.google.zetasql.resolvedast.ResolvedWindowFrameEnums.FrameUnit;
import com.google.zetasql.resolvedast.ResolvedWindowFrameExprEnums.BoundaryType;
import com.google.zetasql.AnyResolvedAggregateScanBaseProto;
import com.google.zetasql.AnyResolvedAlterActionProto;
import com.google.zetasql.AnyResolvedAlterColumnActionProto;
import com.google.zetasql.AnyResolvedAlterObjectStmtProto;
import com.google.zetasql.AnyResolvedArgumentProto;
import com.google.zetasql.AnyResolvedComputedColumnBaseProto;
import com.google.zetasql.AnyResolvedComputedColumnImplProto;
import com.google.zetasql.AnyResolvedConstraintProto;
import com.google.zetasql.AnyResolvedCreateSchemaStmtBaseProto;
import com.google.zetasql.AnyResolvedCreateStatementProto;
import com.google.zetasql.AnyResolvedCreateTableStmtBaseProto;
import com.google.zetasql.AnyResolvedCreateViewBaseProto;
import com.google.zetasql.AnyResolvedExprProto;
import com.google.zetasql.AnyResolvedFunctionCallBaseProto;
import com.google.zetasql.AnyResolvedGrantOrRevokeStmtProto;
import com.google.zetasql.AnyResolvedGraphElementScanProto;
import com.google.zetasql.AnyResolvedGraphLabelExprProto;
import com.google.zetasql.AnyResolvedGraphPathScanBaseProto;
import com.google.zetasql.AnyResolvedGraphScanBaseProto;
import com.google.zetasql.AnyResolvedGroupingSetBaseProto;
import com.google.zetasql.AnyResolvedMatchRecognizePatternExprProto;
import com.google.zetasql.AnyResolvedNonScalarFunctionCallBaseProto;
import com.google.zetasql.AnyResolvedScanProto;
import com.google.zetasql.AnyResolvedStatementProto;
import com.google.zetasql.ResolvedAbortBatchStmtProto;
import com.google.zetasql.ResolvedAddColumnActionProto;
import com.google.zetasql.ResolvedAddConstraintActionProto;
import com.google.zetasql.ResolvedAddSubEntityActionProto;
import com.google.zetasql.ResolvedAddToRestricteeListActionProto;
import com.google.zetasql.ResolvedAggregateFunctionCallProto;
import com.google.zetasql.ResolvedAggregateHavingModifierProto;
import com.google.zetasql.ResolvedAggregateScanProto;
import com.google.zetasql.ResolvedAggregateScanBaseProto;
import com.google.zetasql.ResolvedAggregationThresholdAggregateScanProto;
import com.google.zetasql.ResolvedAlterActionProto;
import com.google.zetasql.ResolvedAlterAllRowAccessPoliciesStmtProto;
import com.google.zetasql.ResolvedAlterApproxViewStmtProto;
import com.google.zetasql.ResolvedAlterColumnActionProto;
import com.google.zetasql.ResolvedAlterColumnDropDefaultActionProto;
import com.google.zetasql.ResolvedAlterColumnDropGeneratedActionProto;
import com.google.zetasql.ResolvedAlterColumnDropNotNullActionProto;
import com.google.zetasql.ResolvedAlterColumnOptionsActionProto;
import com.google.zetasql.ResolvedAlterColumnSetDataTypeActionProto;
import com.google.zetasql.ResolvedAlterColumnSetDefaultActionProto;
import com.google.zetasql.ResolvedAlterConnectionStmtProto;
import com.google.zetasql.ResolvedAlterDatabaseStmtProto;
import com.google.zetasql.ResolvedAlterEntityStmtProto;
import com.google.zetasql.ResolvedAlterExternalSchemaStmtProto;
import com.google.zetasql.ResolvedAlterMaterializedViewStmtProto;
import com.google.zetasql.ResolvedAlterModelStmtProto;
import com.google.zetasql.ResolvedAlterObjectStmtProto;
import com.google.zetasql.ResolvedAlterPrivilegeRestrictionStmtProto;
import com.google.zetasql.ResolvedAlterRowAccessPolicyStmtProto;
import com.google.zetasql.ResolvedAlterSchemaStmtProto;
import com.google.zetasql.ResolvedAlterSubEntityActionProto;
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.ResolvedAnalyzeStmtProto;
import com.google.zetasql.ResolvedAnonymizedAggregateScanProto;
import com.google.zetasql.ResolvedArgumentProto;
import com.google.zetasql.ResolvedArgumentDefProto;
import com.google.zetasql.ResolvedArgumentListProto;
import com.google.zetasql.ResolvedArgumentRefProto;
import com.google.zetasql.ResolvedArrayAggregateProto;
import com.google.zetasql.ResolvedArrayScanProto;
import com.google.zetasql.ResolvedAssertRowsModifiedProto;
import com.google.zetasql.ResolvedAssertScanProto;
import com.google.zetasql.ResolvedAssertStmtProto;
import com.google.zetasql.ResolvedAssignmentStmtProto;
import com.google.zetasql.ResolvedAuxLoadDataPartitionFilterProto;
import com.google.zetasql.ResolvedAuxLoadDataStmtProto;
import com.google.zetasql.ResolvedBarrierScanProto;
import com.google.zetasql.ResolvedBeginStmtProto;
import com.google.zetasql.ResolvedCallStmtProto;
import com.google.zetasql.ResolvedCastProto;
import com.google.zetasql.ResolvedCatalogColumnRefProto;
import com.google.zetasql.ResolvedCheckConstraintProto;
import com.google.zetasql.ResolvedCloneDataStmtProto;
import com.google.zetasql.ResolvedColumnAnnotationsProto;
import com.google.zetasql.ResolvedColumnDefaultValueProto;
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.ResolvedComputedColumnBaseProto;
import com.google.zetasql.ResolvedComputedColumnImplProto;
import com.google.zetasql.ResolvedConnectionProto;
import com.google.zetasql.ResolvedConstantProto;
import com.google.zetasql.ResolvedConstraintProto;
import com.google.zetasql.ResolvedCreateApproxViewStmtProto;
import com.google.zetasql.ResolvedCreateConnectionStmtProto;
import com.google.zetasql.ResolvedCreateConstantStmtProto;
import com.google.zetasql.ResolvedCreateDatabaseStmtProto;
import com.google.zetasql.ResolvedCreateEntityStmtProto;
import com.google.zetasql.ResolvedCreateExternalSchemaStmtProto;
import com.google.zetasql.ResolvedCreateExternalTableStmtProto;
import com.google.zetasql.ResolvedCreateFunctionStmtProto;
import com.google.zetasql.ResolvedCreateIndexStmtProto;
import com.google.zetasql.ResolvedCreateMaterializedViewStmtProto;
import com.google.zetasql.ResolvedCreateModelAliasedQueryProto;
import com.google.zetasql.ResolvedCreateModelStmtProto;
import com.google.zetasql.ResolvedCreatePrivilegeRestrictionStmtProto;
import com.google.zetasql.ResolvedCreateProcedureStmtProto;
import com.google.zetasql.ResolvedCreatePropertyGraphStmtProto;
import com.google.zetasql.ResolvedCreateRowAccessPolicyStmtProto;
import com.google.zetasql.ResolvedCreateSchemaStmtProto;
import com.google.zetasql.ResolvedCreateSchemaStmtBaseProto;
import com.google.zetasql.ResolvedCreateSnapshotTableStmtProto;
import com.google.zetasql.ResolvedCreateStatementProto;
import com.google.zetasql.ResolvedCreateTableAsSelectStmtProto;
import com.google.zetasql.ResolvedCreateTableFunctionStmtProto;
import com.google.zetasql.ResolvedCreateTableStmtProto;
import com.google.zetasql.ResolvedCreateTableStmtBaseProto;
import com.google.zetasql.ResolvedCreateViewBaseProto;
import com.google.zetasql.ResolvedCreateViewStmtProto;
import com.google.zetasql.ResolvedCubeProto;
import com.google.zetasql.ResolvedDMLDefaultProto;
import com.google.zetasql.ResolvedDMLValueProto;
import com.google.zetasql.ResolvedDeferredComputedColumnProto;
import com.google.zetasql.ResolvedDefineTableStmtProto;
import com.google.zetasql.ResolvedDeleteStmtProto;
import com.google.zetasql.ResolvedDescribeStmtProto;
import com.google.zetasql.ResolvedDescriptorProto;
import com.google.zetasql.ResolvedDifferentialPrivacyAggregateScanProto;
import com.google.zetasql.ResolvedDropColumnActionProto;
import com.google.zetasql.ResolvedDropConstraintActionProto;
import com.google.zetasql.ResolvedDropFunctionStmtProto;
import com.google.zetasql.ResolvedDropIndexStmtProto;
import com.google.zetasql.ResolvedDropMaterializedViewStmtProto;
import com.google.zetasql.ResolvedDropPrimaryKeyActionProto;
import com.google.zetasql.ResolvedDropPrivilegeRestrictionStmtProto;
import com.google.zetasql.ResolvedDropRowAccessPolicyStmtProto;
import com.google.zetasql.ResolvedDropSnapshotTableStmtProto;
import com.google.zetasql.ResolvedDropStmtProto;
import com.google.zetasql.ResolvedDropSubEntityActionProto;
import com.google.zetasql.ResolvedDropTableFunctionStmtProto;
import com.google.zetasql.ResolvedExecuteAsRoleScanProto;
import com.google.zetasql.ResolvedExecuteImmediateArgumentProto;
import com.google.zetasql.ResolvedExecuteImmediateStmtProto;
import com.google.zetasql.ResolvedExplainStmtProto;
import com.google.zetasql.ResolvedExportDataStmtProto;
import com.google.zetasql.ResolvedExportMetadataStmtProto;
import com.google.zetasql.ResolvedExportModelStmtProto;
import com.google.zetasql.ResolvedExprProto;
import com.google.zetasql.ResolvedExpressionColumnProto;
import com.google.zetasql.ResolvedExtendedCastProto;
import com.google.zetasql.ResolvedExtendedCastElementProto;
import com.google.zetasql.ResolvedFilterFieldProto;
import com.google.zetasql.ResolvedFilterFieldArgProto;
import com.google.zetasql.ResolvedFilterScanProto;
import com.google.zetasql.ResolvedFilterUsingActionProto;
import com.google.zetasql.ResolvedFlattenProto;
import com.google.zetasql.ResolvedFlattenedArgProto;
import com.google.zetasql.ResolvedForeignKeyProto;
import com.google.zetasql.ResolvedFunctionArgumentProto;
import com.google.zetasql.ResolvedFunctionCallProto;
import com.google.zetasql.ResolvedFunctionCallBaseProto;
import com.google.zetasql.ResolvedFunctionSignatureHolderProto;
import com.google.zetasql.ResolvedGeneralizedQueryStmtProto;
import com.google.zetasql.ResolvedGeneralizedQuerySubpipelineProto;
import com.google.zetasql.ResolvedGeneratedColumnInfoProto;
import com.google.zetasql.ResolvedGetJsonFieldProto;
import com.google.zetasql.ResolvedGetProtoFieldProto;
import com.google.zetasql.ResolvedGetProtoOneofProto;
import com.google.zetasql.ResolvedGetStructFieldProto;
import com.google.zetasql.ResolvedGrantOrRevokeStmtProto;
import com.google.zetasql.ResolvedGrantStmtProto;
import com.google.zetasql.ResolvedGrantToActionProto;
import com.google.zetasql.ResolvedGraphEdgeScanProto;
import com.google.zetasql.ResolvedGraphElementIdentifierProto;
import com.google.zetasql.ResolvedGraphElementLabelProto;
import com.google.zetasql.ResolvedGraphElementPropertyProto;
import com.google.zetasql.ResolvedGraphElementScanProto;
import com.google.zetasql.ResolvedGraphElementTableProto;
import com.google.zetasql.ResolvedGraphGetElementPropertyProto;
import com.google.zetasql.ResolvedGraphIsLabeledPredicateProto;
import com.google.zetasql.ResolvedGraphLabelProto;
import com.google.zetasql.ResolvedGraphLabelExprProto;
import com.google.zetasql.ResolvedGraphLabelNaryExprProto;
import com.google.zetasql.ResolvedGraphLinearScanProto;
import com.google.zetasql.ResolvedGraphMakeArrayVariableProto;
import com.google.zetasql.ResolvedGraphMakeElementProto;
import com.google.zetasql.ResolvedGraphNodeScanProto;
import com.google.zetasql.ResolvedGraphNodeTableReferenceProto;
import com.google.zetasql.ResolvedGraphPathModeProto;
import com.google.zetasql.ResolvedGraphPathPatternQuantifierProto;
import com.google.zetasql.ResolvedGraphPathScanProto;
import com.google.zetasql.ResolvedGraphPathScanBaseProto;
import com.google.zetasql.ResolvedGraphPathSearchPrefixProto;
import com.google.zetasql.ResolvedGraphPropertyDeclarationProto;
import com.google.zetasql.ResolvedGraphPropertyDefinitionProto;
import com.google.zetasql.ResolvedGraphRefScanProto;
import com.google.zetasql.ResolvedGraphScanProto;
import com.google.zetasql.ResolvedGraphScanBaseProto;
import com.google.zetasql.ResolvedGraphTableScanProto;
import com.google.zetasql.ResolvedGraphWildCardLabelProto;
import com.google.zetasql.ResolvedGroupRowsScanProto;
import com.google.zetasql.ResolvedGroupingCallProto;
import com.google.zetasql.ResolvedGroupingSetProto;
import com.google.zetasql.ResolvedGroupingSetBaseProto;
import com.google.zetasql.ResolvedGroupingSetMultiColumnProto;
import com.google.zetasql.ResolvedIdentityColumnInfoProto;
import com.google.zetasql.ResolvedImportStmtProto;
import com.google.zetasql.ResolvedIndexItemProto;
import com.google.zetasql.ResolvedInlineLambdaProto;
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.ResolvedLockModeProto;
import com.google.zetasql.ResolvedLogScanProto;
import com.google.zetasql.ResolvedMakeProtoProto;
import com.google.zetasql.ResolvedMakeProtoFieldProto;
import com.google.zetasql.ResolvedMakeStructProto;
import com.google.zetasql.ResolvedMatchRecognizePatternAnchorProto;
import com.google.zetasql.ResolvedMatchRecognizePatternEmptyProto;
import com.google.zetasql.ResolvedMatchRecognizePatternExprProto;
import com.google.zetasql.ResolvedMatchRecognizePatternOperationProto;
import com.google.zetasql.ResolvedMatchRecognizePatternQuantificationProto;
import com.google.zetasql.ResolvedMatchRecognizePatternVariableRefProto;
import com.google.zetasql.ResolvedMatchRecognizeScanProto;
import com.google.zetasql.ResolvedMatchRecognizeVariableDefinitionProto;
import com.google.zetasql.ResolvedMeasureGroupProto;
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.ResolvedObjectUnitProto;
import com.google.zetasql.ResolvedOnConflictClauseProto;
import com.google.zetasql.ResolvedOptionProto;
import com.google.zetasql.ResolvedOrderByItemProto;
import com.google.zetasql.ResolvedOrderByScanProto;
import com.google.zetasql.ResolvedOutputColumnProto;
import com.google.zetasql.ResolvedOutputSchemaProto;
import com.google.zetasql.ResolvedParameterProto;
import com.google.zetasql.ResolvedPipeExportDataScanProto;
import com.google.zetasql.ResolvedPipeForkScanProto;
import com.google.zetasql.ResolvedPipeIfCaseProto;
import com.google.zetasql.ResolvedPipeIfScanProto;
import com.google.zetasql.ResolvedPivotColumnProto;
import com.google.zetasql.ResolvedPivotScanProto;
import com.google.zetasql.ResolvedPrimaryKeyProto;
import com.google.zetasql.ResolvedPrivilegeProto;
import com.google.zetasql.ResolvedProjectScanProto;
import com.google.zetasql.ResolvedQueryStmtProto;
import com.google.zetasql.ResolvedRecursionDepthModifierProto;
import com.google.zetasql.ResolvedRecursiveRefScanProto;
import com.google.zetasql.ResolvedRecursiveScanProto;
import com.google.zetasql.ResolvedRelationArgumentScanProto;
import com.google.zetasql.ResolvedRemoveFromRestricteeListActionProto;
import com.google.zetasql.ResolvedRenameColumnActionProto;
import com.google.zetasql.ResolvedRenameStmtProto;
import com.google.zetasql.ResolvedRenameToActionProto;
import com.google.zetasql.ResolvedReplaceFieldProto;
import com.google.zetasql.ResolvedReplaceFieldItemProto;
import com.google.zetasql.ResolvedRestrictToActionProto;
import com.google.zetasql.ResolvedReturningClauseProto;
import com.google.zetasql.ResolvedRevokeFromActionProto;
import com.google.zetasql.ResolvedRevokeStmtProto;
import com.google.zetasql.ResolvedRollbackStmtProto;
import com.google.zetasql.ResolvedRollupProto;
import com.google.zetasql.ResolvedRunBatchStmtProto;
import com.google.zetasql.ResolvedSampleScanProto;
import com.google.zetasql.ResolvedScanProto;
import com.google.zetasql.ResolvedSequenceProto;
import com.google.zetasql.ResolvedSetAsActionProto;
import com.google.zetasql.ResolvedSetCollateClauseProto;
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.ResolvedStaticDescribeScanProto;
import com.google.zetasql.ResolvedSubpipelineProto;
import com.google.zetasql.ResolvedSubpipelineInputScanProto;
import com.google.zetasql.ResolvedSubqueryExprProto;
import com.google.zetasql.ResolvedSystemVariableProto;
import com.google.zetasql.ResolvedTVFScanProto;
import com.google.zetasql.ResolvedTableAndColumnInfoProto;
import com.google.zetasql.ResolvedTableScanProto;
import com.google.zetasql.ResolvedTruncateStmtProto;
import com.google.zetasql.ResolvedUndropStmtProto;
import com.google.zetasql.ResolvedUnnestItemProto;
import com.google.zetasql.ResolvedUnpivotArgProto;
import com.google.zetasql.ResolvedUnpivotScanProto;
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.ResolvedWithExprProto;
import com.google.zetasql.ResolvedWithPartitionColumnsProto;
import com.google.zetasql.ResolvedWithRefScanProto;
import com.google.zetasql.ResolvedWithScanProto;
import java.util.List;
import javax.annotation.Nullable;

/**
 * This is a dummy implementation of AnnotationMap.
 * TODO: implement AnnotationMap in
 *   package com.google.zetasql
 */
final class AnnotationMap {
  public AnnotationMap() {
  }

  public AnnotationMapProto serialize(
      FileDescriptorSetsBuilder fileDescriptorSetsBuilder) {
    return AnnotationMapProto.getDefaultInstance();
  }

  public String debugString() {
    return "";
  }
}

/**
 * This is a dummy implementation of ResolvedCollation.
 * TODO: implement ResolvedCollation in
 *   package com.google.zetasql
 */
final class ResolvedCollation {
  public ResolvedCollation() {
  }

  public ResolvedCollationProto serialize() {
    return ResolvedCollationProto.getDefaultInstance();
  }

  public static ResolvedCollation deserialize(ResolvedCollationProto proto) {
    return new ResolvedCollation();
  }

  public String debugString() {
    return "";
  }
}

/**
 * This is a dummy implementation of TypeModifiers and currently only support
 * type_parameters.
 * TODO: implement TypeModifiers in
 *   package com.google.zetasql
 */
final class TypeModifiers{
  private TypeParameters type_parameters;

  public TypeModifiers() {
    type_parameters = new TypeParameters();
  }

  public TypeModifiers(TypeParameters type_parameters) {
    this.type_parameters = type_parameters;
  }

  public boolean isEmpty() {
    return type_parameters.isEmpty();
  }

  public TypeModifiersProto serialize() {
    TypeModifiersProto.Builder builder = TypeModifiersProto.newBuilder();
    builder.setTypeParameters(this.type_parameters.serialize());
    return builder.build();
  }

  public static TypeModifiers deserialize(TypeModifiersProto proto) {
    if (proto.hasTypeParameters()) {
      return new TypeModifiers(TypeParameters.deserialize(proto.getTypeParameters()));
    }
    return new TypeModifiers();
  }

  public String debugString() {
    if (isEmpty()) {
      return "null";
    }
    return "type_parameters:" + this.type_parameters.debugString();
  }
}

/**
 * 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) { if (functionSignature == null) return null; 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.getDescriptorPool())); fieldDescriptorRef.setContainingProto(proto.build()); fieldDescriptorRef.setNumber(fieldDescriptor.getNumber()); return fieldDescriptorRef.build(); } static OneofDescriptorRefProto serialize(ZetaSQLOneofDescriptor descriptor, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { OneofDescriptorRefProto.Builder oneOfDescriptorRef = OneofDescriptorRefProto.newBuilder(); ProtoTypeProto.Builder proto = ProtoTypeProto.newBuilder(); OneofDescriptor oneOfDescriptor = descriptor.getDescriptor(); proto.setProtoName(oneOfDescriptor.getContainingType().getFullName()); proto.setProtoFileName(oneOfDescriptor.getFile().getName()); proto.setFileDescriptorSetIndex( fileDescriptorSetsBuilder.getOrAddFileDescriptorIndex( oneOfDescriptor.getFile(), descriptor.getDescriptorPool())); oneOfDescriptorRef.setContainingProto(proto.build()); oneOfDescriptorRef.setIndex(oneOfDescriptor.getIndex()); return oneOfDescriptorRef.build(); } static ResolvedFunctionCallInfoProto serialize( ResolvedFunctionCallInfo functionCallContext, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return ResolvedFunctionCallInfoProto.getDefaultInstance(); } static TVFSignatureProto serialize( TVFSignature tvfSignature, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return tvfSignature.serialize(fileDescriptorSetsBuilder); } static TableValuedFunctionRefProto serialize( TableValuedFunction tvf, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return TableValuedFunctionRefProto.newBuilder().setName(tvf.getName()).build(); } static ModelRefProto serialize(Model model, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return ModelRefProto.newBuilder().setName(model.getName()).setSerializationId(model.getId()).build(); } static ConnectionRefProto serialize(Connection connection, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return ConnectionRefProto.newBuilder().setName(connection.getName()).setFullName(connection.getFullName()).build(); } static SequenceRefProto serialize(Sequence sequence, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return SequenceRefProto.newBuilder().setName(sequence.getName()).build(); } static ProcedureRefProto serialize(Procedure procedure, @SuppressWarnings("unused") FileDescriptorSetsBuilder unused) { return ProcedureRefProto.newBuilder().setName(procedure.getFullName()).build(); } static TableRefProto serialize(Table table, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return TableRefProto.newBuilder() .setName(table.getName()) .setFullName(table.getFullName()) .setSerializationId(table.getId()).build(); } static ColumnRefProto serialize(Column column, @SuppressWarnings("unused") FileDescriptorSetsBuilder unused) { String colFullName = column.getFullName(); int pos = colFullName.lastIndexOf('.'); TableRefProto table; if(pos == -1) { return ColumnRefProto.newBuilder() .setName(column.getName()) .build(); } String tableFullName = colFullName.substring(0, pos); String[] namePath = tableFullName.split("\\."); return ColumnRefProto.newBuilder() .setName(column.getName()) .setTableRef( TableRefProto.newBuilder() .setName(namePath[namePath.length-1]) .setFullName(tableFullName)) .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(); } static AnnotationMapProto serialize( AnnotationMap annotationMap, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return annotationMap.serialize(fileDescriptorSetsBuilder); } static ResolvedCollationProto serialize( ResolvedCollation resolvedCollation, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return resolvedCollation.serialize(); } static TypeModifiersProto serialize( TypeModifiers typeModifiers, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return typeModifiers.serialize(); } static TypeParametersProto serialize( TypeParameters typeParameters, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return typeParameters.serialize(); } static PropertyGraphRefProto serialize( PropertyGraph propertyGraph, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { return PropertyGraphRefProto.newBuilder() .setFullName(propertyGraph.getFullName()).build(); } static GraphPropertyDeclarationRefProto serialize( GraphPropertyDeclaration graphPropertyDeclaration, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { String fullName = graphPropertyDeclaration.getFullName(); int pos = fullName.lastIndexOf('.'); Preconditions.checkArgument(pos != -1); return GraphPropertyDeclarationRefProto.newBuilder() .setName(graphPropertyDeclaration.getName()) .setPropertyGraph( PropertyGraphRefProto.newBuilder() .setFullName(fullName.substring(0, pos)) ) .build(); } static GraphElementLabelRefProto serialize( GraphElementLabel graphElementLabel, FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { // The label full name consists of three parts , // , and

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; /** * Indicates whether ReplaceLiteralsByParameters() should leave * this literal value in place, rather than replace it with a query * parameter. */ private final boolean preserveInLiteralRemover; ResolvedLiteral(ResolvedLiteralProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); value = helper.deserialize(proto.getValue()); hasExplicitType = proto.getHasExplicitType(); floatLiteralId = proto.getFloatLiteralId(); preserveInLiteralRemover = proto.getPreserveInLiteralRemover(); } ResolvedLiteral( Type type, AnnotationMap typeAnnotationMap, Value value, boolean hasExplicitType, long floatLiteralId, boolean preserveInLiteralRemover) { super( type, typeAnnotationMap); this.value = value; this.hasExplicitType = hasExplicitType; this.floatLiteralId = floatLiteralId; this.preserveInLiteralRemover = preserveInLiteralRemover; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.value = this.getValue(); builder.hasExplicitType = this.getHasExplicitType(); builder.floatLiteralId = this.getFloatLiteralId(); builder.preserveInLiteralRemover = this.getPreserveInLiteralRemover(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected Value value = null; protected boolean hasExplicitType = false; protected long floatLiteralId = 0; protected boolean preserveInLiteralRemover = false; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setValue(Value v) { this.value = v; Preconditions.checkNotNull(v, "value must not be null"); return this; } /** * If true, then the literal is explicitly typed and cannot be used * for literal coercions. * *

This exists mainly for resolver bookkeeping and should be ignored * by engines. */ @CanIgnoreReturnValue public Builder setHasExplicitType(boolean v) { this.hasExplicitType = v; return this; } /** * Distinct ID of the literal, if it is a floating point value, * within the resolved AST. When coercing from floating point * to NUMERIC, the resolver uses the float_literal_id to find the * original image of the literal to avoid precision loss. An ID of 0 * represents a literal without a cached image. */ @CanIgnoreReturnValue public Builder setFloatLiteralId(long v) { this.floatLiteralId = v; return this; } /** * Indicates whether ReplaceLiteralsByParameters() should leave * this literal value in place, rather than replace it with a query * parameter. */ @CanIgnoreReturnValue public Builder setPreserveInLiteralRemover(boolean v) { this.preserveInLiteralRemover = v; return this; } @Override public final ResolvedLiteral build() { validate(); return new ResolvedLiteral( type, typeAnnotationMap, value, hasExplicitType, floatLiteralId, preserveInLiteralRemover); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( value != null, "value must be set"); } } public static final ResolvedLiteral deserialize( ResolvedLiteralProto proto, AbstractDeserializationHelper 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()); // preserveInLiteralRemover is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setPreserveInLiteralRemover(this.getPreserveInLiteralRemover()); } 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; } /** * Indicates whether ReplaceLiteralsByParameters() should leave * this literal value in place, rather than replace it with a query * parameter. */ public final boolean getPreserveInLiteralRemover() { return preserveInLiteralRemover; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedLiteral accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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))); } if (!DebugStrings.isDefaultValue(preserveInLiteralRemover)) { fields.add(new DebugStringField("preserve_in_literal_remover", DebugStrings.toStringImpl(preserveInLiteralRemover))); } } } public static final class ResolvedParameter extends ResolvedExpr { /** * If non-empty, the name of the parameter. * *

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

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

This exists mainly for resolver bookkeeping and should be ignored * by engines. */ private final boolean isUntyped; ResolvedParameter(ResolvedParameterProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); position = proto.getPosition(); isUntyped = proto.getIsUntyped(); } ResolvedParameter( Type type, AnnotationMap typeAnnotationMap, String name, long position, boolean isUntyped) { super( type, typeAnnotationMap); this.name = name; this.position = position; this.isUntyped = isUntyped; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.name = this.getName(); builder.position = this.getPosition(); builder.isUntyped = this.getIsUntyped(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected String name = null; protected long position = 0; protected boolean isUntyped = false; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } /** * If non-empty, the name of the parameter. * *

A ResolvedParameter will have either a name or a position but not * both. */ @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; return this; } /** * If non-zero, the 1-based position of the positional parameter. * *

A ResolvedParameter will have either a name or a position but not * both. */ @CanIgnoreReturnValue public Builder setPosition(long v) { this.position = v; return this; } /** * If true, then the parameter has no specified type. * *

This exists mainly for resolver bookkeeping and should be ignored * by engines. */ @CanIgnoreReturnValue public Builder setIsUntyped(boolean v) { this.isUntyped = v; return this; } @Override public final ResolvedParameter build() { validate(); return new ResolvedParameter( type, typeAnnotationMap, name, position, isUntyped); } @Override protected void validate() { super.validate(); } } public static final ResolvedParameter deserialize( ResolvedParameterProto proto, AbstractDeserializationHelper 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 public ResolvedParameter accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(name)) { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (!DebugStrings.isDefaultValue(position)) { fields.add(new DebugStringField("position", DebugStrings.toStringImpl(position))); } if (!DebugStrings.isDefaultValue(isUntyped)) { fields.add(new DebugStringField("is_untyped", DebugStrings.toStringImpl(isUntyped))); } } } /** * This represents a column when analyzing a standalone expression. * This is only used when the analyzer was called using AnalyzeExpression. * Expression column names and types come from * AnalyzerOptions::AddExpressionColumn. * will always be in lowercase. */ public static final class ResolvedExpressionColumn extends ResolvedExpr { private final String name; ResolvedExpressionColumn(ResolvedExpressionColumnProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); } ResolvedExpressionColumn( Type type, AnnotationMap typeAnnotationMap, String name) { super( type, typeAnnotationMap); this.name = name; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.name = this.getName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected String name = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @Override public final ResolvedExpressionColumn build() { validate(); return new ResolvedExpressionColumn( type, typeAnnotationMap, name); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); } } public static final ResolvedExpressionColumn deserialize( ResolvedExpressionColumnProto proto, AbstractDeserializationHelper 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 public ResolvedExpressionColumn accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } } } /** * An expression referencing a Column from the Catalog. This is used to * represent a column reference in an expression inside a DDL statement. * The DDL statement will normally define the Table context, and the * referenced Column should be a Column of that Table. */ public static final class ResolvedCatalogColumnRef extends ResolvedExpr { private final Column column; ResolvedCatalogColumnRef(ResolvedCatalogColumnRefProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); column = helper.deserialize(proto.getColumn()); } ResolvedCatalogColumnRef( Type type, AnnotationMap typeAnnotationMap, Column column) { super( type, typeAnnotationMap); this.column = column; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.column = this.getColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected Column column = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setColumn(Column v) { this.column = v; Preconditions.checkNotNull(v, "column must not be null"); return this; } @Override public final ResolvedCatalogColumnRef build() { validate(); return new ResolvedCatalogColumnRef( type, typeAnnotationMap, column); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( column != null, "column must be set"); } } public static final ResolvedCatalogColumnRef deserialize( ResolvedCatalogColumnRefProto proto, AbstractDeserializationHelper helper) { return new ResolvedCatalogColumnRef(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CATALOG_COLUMN_REF; } @Override public final String nodeKindString() { return "CatalogColumnRef"; } /** * 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(); ResolvedCatalogColumnRefProto.Builder childBuilder = ResolvedCatalogColumnRefProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCatalogColumnRefNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCatalogColumnRefProto.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, ResolvedCatalogColumnRefProto.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)); } } public final Column getColumn() { return column; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCatalogColumnRef accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("column", DebugStrings.toStringImpl(column))); } } } /** * An expression referencing the value of some column visible in the * current Scan node. * *

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

If is true, this references a column from outside a * subquery that is visible as a correlated column inside. * The column referenced here must show up on the parameters list for the * subquery. See ResolvedSubqueryExpr. */ public static final class ResolvedColumnRef extends ResolvedExpr { private final ResolvedColumn column; private final boolean isCorrelated; ResolvedColumnRef(ResolvedColumnRefProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); column = helper.deserialize(proto.getColumn()); isCorrelated = proto.getIsCorrelated(); } ResolvedColumnRef( Type type, AnnotationMap typeAnnotationMap, ResolvedColumn column, boolean isCorrelated) { super( type, typeAnnotationMap); this.column = column; this.isCorrelated = isCorrelated; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.column = this.getColumn(); builder.isCorrelated = this.getIsCorrelated(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedColumn column = null; protected Boolean isCorrelated = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setColumn(ResolvedColumn v) { this.column = v; Preconditions.checkNotNull(v, "column must not be null"); return this; } @CanIgnoreReturnValue public Builder setIsCorrelated(boolean v) { this.isCorrelated = v; return this; } @Override public final ResolvedColumnRef build() { validate(); return new ResolvedColumnRef( type, typeAnnotationMap, column, isCorrelated); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( column != null, "column must be set"); } } public static final ResolvedColumnRef deserialize( ResolvedColumnRefProto proto, AbstractDeserializationHelper 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 public ResolvedColumnRef accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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 list of ResolvedColumnRef expression references that will be batched * together in rollup/cube when being expanded to grouping sets. For * example, ROLLUP((a, b), c) will be expanded to 3 grouping sets [(a, b, c), * (a, b), ()], (a, b) is a multi-column. * *

Duplicated columns are not allowed in the ResolvedGroupingSetMultiColumn * as they are equivalent to deduplicated columns. column_list must have * at least one element inside. */ public static final class ResolvedGroupingSetMultiColumn extends ResolvedArgument { private final ImmutableList columnList; ResolvedGroupingSetMultiColumn(ResolvedGroupingSetMultiColumnProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder columnListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getColumnListList()) { columnListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } columnList = columnListBuilder.build(); } ResolvedGroupingSetMultiColumn( ImmutableList columnList) { super(); this.columnList = columnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList columnList = null; private Builder() {} @CanIgnoreReturnValue public Builder setColumnList(List v) { this.columnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGroupingSetMultiColumn build() { validate(); return new ResolvedGroupingSetMultiColumn( columnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( columnList != null, "columnList must be set"); } } public static final ResolvedGroupingSetMultiColumn deserialize( ResolvedGroupingSetMultiColumnProto proto, AbstractDeserializationHelper helper) { return new ResolvedGroupingSetMultiColumn(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GROUPING_SET_MULTI_COLUMN; } @Override public final String nodeKindString() { return "GroupingSetMultiColumn"; } /** * 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(); ResolvedGroupingSetMultiColumnProto.Builder childBuilder = ResolvedGroupingSetMultiColumnProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGroupingSetMultiColumnNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGroupingSetMultiColumnProto.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, ResolvedGroupingSetMultiColumnProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // columnList is a collection of AST nodes. Serialize each of them. ImmutableList columnLists = this.getColumnList(); for (ResolvedColumnRef element : columnLists) { ResolvedColumnRefProto.Builder columnListBuilder = ResolvedColumnRefProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, columnListBuilder); proto.addColumnList(columnListBuilder.build()); } } public final ImmutableList getColumnList() { return columnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGroupingSetMultiColumn accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!columnList.isEmpty()) { fields.add(new DebugStringField("column_list", columnList)); } } } /** * A reference to a named constant. */ public static final class ResolvedConstant extends ResolvedExpr { /** * The matching Constant from the Catalog. */ private final Constant constant; ResolvedConstant(ResolvedConstantProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); constant = helper.deserialize(proto.getConstant()); } ResolvedConstant( Type type, AnnotationMap typeAnnotationMap, Constant constant) { super( type, typeAnnotationMap); this.constant = constant; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.constant = this.getConstant(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected Constant constant = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } /** * The matching Constant from the Catalog. */ @CanIgnoreReturnValue public Builder setConstant(Constant v) { this.constant = v; Preconditions.checkNotNull(v, "constant must not be null"); return this; } @Override public final ResolvedConstant build() { validate(); return new ResolvedConstant( type, typeAnnotationMap, constant); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( constant != null, "constant must be set"); } } public static final ResolvedConstant deserialize( ResolvedConstantProto proto, AbstractDeserializationHelper 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 public ResolvedConstant accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * A reference to a system variable. */ public static final class ResolvedSystemVariable extends ResolvedExpr { /** * Path to system variable. */ private final ImmutableList namePath; ResolvedSystemVariable(ResolvedSystemVariableProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); } ResolvedSystemVariable( Type type, AnnotationMap typeAnnotationMap, ImmutableList namePath) { super( type, typeAnnotationMap); this.namePath = namePath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.namePath = this.getNamePath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ImmutableList namePath = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } /** * Path to system variable. */ @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedSystemVariable build() { validate(); return new ResolvedSystemVariable( type, typeAnnotationMap, namePath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedSystemVariable deserialize( ResolvedSystemVariableProto proto, AbstractDeserializationHelper 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 public ResolvedSystemVariable accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * A lambda expression, used inline as a function argument. * This represents both the definition of the lambda and the resolution of * its templated signature and body for this function call. * Currently can only be used as an argument of a function. * *

defines the argument types and names for the lambda, and * creates new ResolvedColumns which can be used to reference the arguments * inside . * *

The return type of the lambda function is the type of . * *

In addition to the , the body of a lambda expression can * reference columns visible to the scope of the function call for which this * lambda is provided as an argument. Columns in this scope accessed by the * body are stored in . * *

For example, the following query * SELECT ARRAY_FILTER([1,2,3], e -> e = key) FROM KeyValue; * would have a lambda with ['key'] and * ['e']. * *

is the body expression of the lambda. The expression can only * reference columns in and . */ public static final class ResolvedInlineLambda extends ResolvedArgument { private final ImmutableList argumentList; private final ImmutableList parameterList; private final ResolvedExpr body; ResolvedInlineLambda(ResolvedInlineLambdaProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder argumentListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getArgumentListList()) { argumentListBuilder.add(helper.deserialize(element)); } argumentList = argumentListBuilder.build(); ImmutableList.Builder parameterListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getParameterListList()) { parameterListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } parameterList = parameterListBuilder.build(); if (proto.hasBody()) { body = ResolvedExpr.deserialize(proto.getBody(), helper); } else { body = null; } } ResolvedInlineLambda( ImmutableList argumentList, ImmutableList parameterList, ResolvedExpr body) { super(); this.argumentList = argumentList; this.parameterList = parameterList; this.body = body; } @Override public Builder toBuilder() { Builder builder = builder(); builder.argumentList = this.getArgumentList(); builder.parameterList = this.getParameterList(); builder.body = this.getBody(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList argumentList = null; protected ImmutableList parameterList = null; protected ResolvedExpr body = null; private Builder() {} @CanIgnoreReturnValue public Builder setArgumentList(List v) { this.argumentList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setParameterList(List v) { this.parameterList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setBody(ResolvedExpr v) { this.body = v; Preconditions.checkNotNull(v, "body must not be null"); return this; } @Override public final ResolvedInlineLambda build() { validate(); return new ResolvedInlineLambda( argumentList, parameterList, body); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( argumentList != null, "argumentList must be set"); Preconditions.checkArgument( parameterList != null, "parameterList must be set"); Preconditions.checkArgument( body != null, "body must be set"); } } public static final ResolvedInlineLambda deserialize( ResolvedInlineLambdaProto proto, AbstractDeserializationHelper helper) { return new ResolvedInlineLambda(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_INLINE_LAMBDA; } @Override public final String nodeKindString() { return "InlineLambda"; } /** * 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(); ResolvedInlineLambdaProto.Builder childBuilder = ResolvedInlineLambdaProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedInlineLambdaNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedInlineLambdaProto.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, ResolvedInlineLambdaProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // argumentList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList argumentLists = this.getArgumentList(); for (ResolvedColumn element : argumentLists) { proto.addArgumentList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // 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()); } // body is an AST node. Call its serialization chain. if (this.getBody() != null) { AnyResolvedExprProto.Builder bodyBuilder = AnyResolvedExprProto.newBuilder(); this.getBody().serialize( fileDescriptorSetsBuilder, bodyBuilder); proto.setBody( bodyBuilder.build()); } } public final ImmutableList getArgumentList() { return argumentList; } public final ImmutableList getParameterList() { return parameterList; } public final ResolvedExpr getBody() { return body; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedInlineLambda accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(parameterList); visitor.descend(body); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("argument_list", DebugStrings.toStringImpl(argumentList))); } if (!parameterList.isEmpty()) { fields.add(new DebugStringField("parameter_list", parameterList)); } if (body != null) { fields.add(new DebugStringField("body", body)); } } } /** * Represents a sequence as a function argument */ public static final class ResolvedSequence extends ResolvedArgument { private final Sequence sequence; ResolvedSequence(ResolvedSequenceProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); sequence = helper.deserialize(proto.getSequence()); } ResolvedSequence( Sequence sequence) { super(); this.sequence = sequence; } @Override public Builder toBuilder() { Builder builder = builder(); builder.sequence = this.getSequence(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected Sequence sequence = null; private Builder() {} @CanIgnoreReturnValue public Builder setSequence(Sequence v) { this.sequence = v; Preconditions.checkNotNull(v, "sequence must not be null"); return this; } @Override public final ResolvedSequence build() { validate(); return new ResolvedSequence( sequence); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( sequence != null, "sequence must be set"); } } public static final ResolvedSequence deserialize( ResolvedSequenceProto proto, AbstractDeserializationHelper helper) { return new ResolvedSequence(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SEQUENCE; } @Override public final String nodeKindString() { return "Sequence"; } /** * 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(); ResolvedSequenceProto.Builder childBuilder = ResolvedSequenceProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSequenceNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSequenceProto.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, ResolvedSequenceProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // sequence is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getSequence() != null) { proto.setSequence( ResolvedNodes.serialize(this.getSequence(), fileDescriptorSetsBuilder)); } } public final Sequence getSequence() { return sequence; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedSequence accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("sequence", DebugStrings.toStringImpl(sequence))); } } } /** * An argument to the FILTER_FIELDS() function which specifies a sign to show * inclusion/exclusion status and a field path to include or exclude. */ public static final class ResolvedFilterFieldArg extends ResolvedArgument { /** * True if we want to include this proto path in the resulting proto * (though we may still remove paths below it). * If False, we will remove this path (but may still include paths * below it). */ private final boolean include; /** * A vector of FieldDescriptors that denotes the path to a proto * field that will be include or exclude. */ private final ImmutableList fieldDescriptorPath; ResolvedFilterFieldArg(ResolvedFilterFieldArgProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); include = proto.getInclude(); ImmutableList.Builder fieldDescriptorPathBuilder = ImmutableList.builder(); for (FieldDescriptorRefProto element : proto.getFieldDescriptorPathList()) { fieldDescriptorPathBuilder.add(helper.deserialize(element)); } fieldDescriptorPath = fieldDescriptorPathBuilder.build(); } ResolvedFilterFieldArg( boolean include, ImmutableList fieldDescriptorPath) { super(); this.include = include; this.fieldDescriptorPath = fieldDescriptorPath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.include = this.getInclude(); builder.fieldDescriptorPath = this.getFieldDescriptorPath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected Boolean include = null; protected ImmutableList fieldDescriptorPath = null; private Builder() {} /** * True if we want to include this proto path in the resulting proto * (though we may still remove paths below it). * If False, we will remove this path (but may still include paths * below it). */ @CanIgnoreReturnValue public Builder setInclude(boolean v) { this.include = v; return this; } /** * A vector of FieldDescriptors that denotes the path to a proto * field that will be include or exclude. */ @CanIgnoreReturnValue public Builder setFieldDescriptorPath(List v) { this.fieldDescriptorPath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedFilterFieldArg build() { validate(); return new ResolvedFilterFieldArg( include, fieldDescriptorPath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( include != null, "include must be set"); Preconditions.checkArgument( fieldDescriptorPath != null, "fieldDescriptorPath must be set"); } } public static final ResolvedFilterFieldArg deserialize( ResolvedFilterFieldArgProto proto, AbstractDeserializationHelper helper) { return new ResolvedFilterFieldArg(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FILTER_FIELD_ARG; } @Override public final String nodeKindString() { return "FilterFieldArg"; } /** * 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(); ResolvedFilterFieldArgProto.Builder childBuilder = ResolvedFilterFieldArgProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFilterFieldArgNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedFilterFieldArgProto.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, ResolvedFilterFieldArgProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // include is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setInclude(this.getInclude()); // fieldDescriptorPath is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList fieldDescriptorPaths = this.getFieldDescriptorPath(); for (ZetaSQLFieldDescriptor element : fieldDescriptorPaths) { proto.addFieldDescriptorPath(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } } /** * True if we want to include this proto path in the resulting proto * (though we may still remove paths below it). * If False, we will remove this path (but may still include paths * below it). */ public final boolean getInclude() { return include; } /** * A vector of FieldDescriptors that denotes the path to a proto * field that will be include or exclude. */ public final ImmutableList getFieldDescriptorPath() { return fieldDescriptorPath; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedFilterFieldArg accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("include", DebugStrings.toStringImpl(include))); } { fields.add(new DebugStringField("field_descriptor_path", DebugStrings.toStringPeriodSeparatedForFieldDescriptors(fieldDescriptorPath))); } } } /** * Represents a call to the FILTER_FIELDS() function. This function can be * used to modify a proto, prune fields and output the resulting proto. The * SQL syntax for this function is * FILTER_FIELDS(, ). * *

must have proto type. contains a sign ('+' or * '-') and a field path starting from the proto. * *

For example: * FILTER_FIELDS(proto, +field1, -field1.field2) * means the resulting proto only contains field1.* except field1.field2.*. * *

Field paths are evaluated and processed in order, * ``` * IF filter_field_arg_list[0].include: * CLEAR all fields * FOR filter_field_arg IN filter_field_arg_list: * IF filter_field_arg.include: * UNCLEAR filter_field_arg.field_descriptor_path (and all children) * ELSE: * CLEAR filter_field_arg.field_descriptor_path (and all children) * ``` * *

The order of field_field args have following constraints: * 1. There must be at least one filter_field arg. * 2. Args for ancestor fields must precede descendants. * 3. Each arg must have opposite `include` compared to the last preceding * ancestor field. * *

See (broken link) for more detail. */ public static final class ResolvedFilterField extends ResolvedExpr { /** * The proto to modify. */ private final ResolvedExpr expr; /** * The list of field paths to include or exclude. The path starts * from the proto type of . */ private final ImmutableList filterFieldArgList; /** * If true, will reset cleared required fields into a * default value. */ private final boolean resetClearedRequiredFields; ResolvedFilterField(ResolvedFilterFieldProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } ImmutableList.Builder filterFieldArgListBuilder = ImmutableList.builder(); for (ResolvedFilterFieldArgProto element : proto.getFilterFieldArgListList()) { filterFieldArgListBuilder .add(ResolvedFilterFieldArg.deserialize(element, helper)); } filterFieldArgList = filterFieldArgListBuilder.build(); resetClearedRequiredFields = proto.getResetClearedRequiredFields(); } ResolvedFilterField( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr expr, ImmutableList filterFieldArgList, boolean resetClearedRequiredFields) { super( type, typeAnnotationMap); this.expr = expr; this.filterFieldArgList = filterFieldArgList; this.resetClearedRequiredFields = resetClearedRequiredFields; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.expr = this.getExpr(); builder.filterFieldArgList = this.getFilterFieldArgList(); builder.resetClearedRequiredFields = this.getResetClearedRequiredFields(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr expr = null; protected ImmutableList filterFieldArgList = null; protected Boolean resetClearedRequiredFields = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } /** * The proto to modify. */ @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } /** * The list of field paths to include or exclude. The path starts * from the proto type of . */ @CanIgnoreReturnValue public Builder setFilterFieldArgList(List v) { this.filterFieldArgList = ImmutableList.copyOf(v); return this; } /** * If true, will reset cleared required fields into a * default value. */ @CanIgnoreReturnValue public Builder setResetClearedRequiredFields(boolean v) { this.resetClearedRequiredFields = v; return this; } @Override public final ResolvedFilterField build() { validate(); return new ResolvedFilterField( type, typeAnnotationMap, expr, filterFieldArgList, resetClearedRequiredFields); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( filterFieldArgList != null, "filterFieldArgList must be set"); Preconditions.checkArgument( resetClearedRequiredFields != null, "resetClearedRequiredFields must be set"); } } public static final ResolvedFilterField deserialize( ResolvedFilterFieldProto proto, AbstractDeserializationHelper helper) { return new ResolvedFilterField(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FILTER_FIELD; } @Override public final String nodeKindString() { return "FilterField"; } /** * 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(); ResolvedFilterFieldProto.Builder childBuilder = ResolvedFilterFieldProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFilterFieldNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedFilterFieldProto.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, ResolvedFilterFieldProto.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()); } // filterFieldArgList is a collection of AST nodes. Serialize each of them. ImmutableList filterFieldArgLists = this.getFilterFieldArgList(); for (ResolvedFilterFieldArg element : filterFieldArgLists) { ResolvedFilterFieldArgProto.Builder filterFieldArgListBuilder = ResolvedFilterFieldArgProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, filterFieldArgListBuilder); proto.addFilterFieldArgList(filterFieldArgListBuilder.build()); } // resetClearedRequiredFields is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setResetClearedRequiredFields(this.getResetClearedRequiredFields()); } /** * The proto to modify. */ public final ResolvedExpr getExpr() { return expr; } /** * The list of field paths to include or exclude. The path starts * from the proto type of . */ public final ImmutableList getFilterFieldArgList() { return filterFieldArgList; } /** * If true, will reset cleared required fields into a * default value. */ public final boolean getResetClearedRequiredFields() { return resetClearedRequiredFields; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedFilterField accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); visitor.descend(filterFieldArgList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } if (!filterFieldArgList.isEmpty()) { fields.add(new DebugStringField("filter_field_arg_list", filterFieldArgList)); } { fields.add(new DebugStringField("reset_cleared_required_fields", DebugStrings.toStringImpl(resetClearedRequiredFields))); } } } /** * Common base class for scalar and aggregate function calls. * *

contains a list of arguments of type ResolvedExpr. * *

contains an alternative list of generic arguments. * This is used for function calls that accept non-expression arguments (i.e. * arguments that aren't part of the type system, like lambdas). * *

If all arguments of this function call are ResolvedExprs, * is used. If any of the argument is not a ResolvedExpr, * will be used. Only one of or * can be non-empty. * *

(only set when FEATURE_V_1_3_COLLATION_SUPPORT is * enabled) is the operation collation to use. * (broken link) lists the functions affected by * collation, where this can show up. * is a vector for future extension. For now, functions * could have at most one element in the . */ 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; private final ImmutableList genericArgumentList; /** * 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; /** * Function call hints. */ private final ImmutableList hintList; private final ImmutableList collationList; ResolvedFunctionCallBase(ResolvedFunctionCallBaseProto proto, AbstractDeserializationHelper 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(); ImmutableList.Builder genericArgumentListBuilder = ImmutableList.builder(); for (ResolvedFunctionArgumentProto element : proto.getGenericArgumentListList()) { genericArgumentListBuilder .add(ResolvedFunctionArgument.deserialize(element, helper)); } genericArgumentList = genericArgumentListBuilder.build(); errorMode = proto.getErrorMode(); ImmutableList.Builder hintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getHintListList()) { hintListBuilder .add(ResolvedOption.deserialize(element, helper)); } hintList = hintListBuilder.build(); ImmutableList.Builder collationListBuilder = ImmutableList.builder(); for (ResolvedCollationProto element : proto.getCollationListList()) { collationListBuilder.add(helper.deserialize(element)); } collationList = collationListBuilder.build(); } ResolvedFunctionCallBase( Type type, AnnotationMap typeAnnotationMap, Function function, FunctionSignature signature, ImmutableList argumentList, ImmutableList genericArgumentList, ErrorMode errorMode, ImmutableList hintList, ImmutableList collationList) { super( type, typeAnnotationMap); this.function = function; this.signature = signature; this.argumentList = argumentList; this.genericArgumentList = genericArgumentList; this.errorMode = errorMode; this.hintList = hintList; this.collationList = collationList; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedExpr.Builder { protected Function function = null; protected FunctionSignature signature = null; protected ImmutableList argumentList = null; protected ImmutableList genericArgumentList = ImmutableList.of(); protected ErrorMode errorMode = null; protected ImmutableList hintList = ImmutableList.of(); protected ImmutableList collationList = ImmutableList.of(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } /** * The matching Function from the Catalog. */ @CanIgnoreReturnValue public Builder setFunction(Function v) { this.function = v; Preconditions.checkNotNull(v, "function must not be null"); return this; } /** * The concrete FunctionSignature reflecting the matching Function * signature and the function's resolved input . * The function has the mode AGGREGATE iff it is an aggregate * function, in which case this node must be either * ResolvedAggregateFunctionCall or ResolvedAnalyticFunctionCall. */ @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { this.signature = v; return this; } @CanIgnoreReturnValue public Builder setArgumentList(List v) { this.argumentList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setGenericArgumentList(List v) { this.genericArgumentList = ImmutableList.copyOf(v); return this; } /** * If error_mode=SAFE_ERROR_MODE, and if this function call returns a * semantic error (based on input data, not transient server * problems), return NULL instead of an error. This is used for * functions called using SAFE, as in SAFE.FUNCTION(...). */ @CanIgnoreReturnValue public Builder setErrorMode(ErrorMode v) { this.errorMode = v; return this; } /** * Function call hints. */ @CanIgnoreReturnValue public Builder setHintList(List v) { this.hintList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setCollationList(List v) { this.collationList = ImmutableList.copyOf(v); return this; } @Override public abstract ResolvedFunctionCallBase build(); @Override protected void validate() { super.validate(); Preconditions.checkArgument( function != null, "function must be set"); } } public static ResolvedFunctionCallBase deserialize( AnyResolvedFunctionCallBaseProto proto, AbstractDeserializationHelper 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()); } // genericArgumentList is a collection of AST nodes. Serialize each of them. ImmutableList genericArgumentLists = this.getGenericArgumentList(); for (ResolvedFunctionArgument element : genericArgumentLists) { ResolvedFunctionArgumentProto.Builder genericArgumentListBuilder = ResolvedFunctionArgumentProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, genericArgumentListBuilder); proto.addGenericArgumentList(genericArgumentListBuilder.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()); // 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()); } // collationList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList collationLists = this.getCollationList(); for (ResolvedCollation element : collationLists) { proto.addCollationList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } } /** * 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; } public final ImmutableList getGenericArgumentList() { return genericArgumentList; } /** * 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; } /** * Function call hints. */ public final ImmutableList getHintList() { return hintList; } public final ImmutableList getCollationList() { return collationList; } @Override public abstract ResolvedFunctionCallBase accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(argumentList); visitor.descend(genericArgumentList); visitor.descend(hintList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * A regular function call. The signature will always have mode SCALAR. * Most scalar expressions show up as FunctionCalls using builtin signatures. */ public static final class ResolvedFunctionCall extends ResolvedFunctionCallBase { /** * This contains optional custom information about a particular * function call. * *

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

This field is ignorable because for most types of function calls, * there is no extra information to consider besides the arguments * and other fields from ResolvedFunctionCallBase. */ private final ResolvedFunctionCallInfo functionCallInfo; ResolvedFunctionCall(ResolvedFunctionCallProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); functionCallInfo = helper.deserialize(proto.getFunctionCallInfo()); } ResolvedFunctionCall( Type type, AnnotationMap typeAnnotationMap, Function function, FunctionSignature signature, ImmutableList argumentList, ImmutableList genericArgumentList, ErrorMode errorMode, ImmutableList hintList, ImmutableList collationList, ResolvedFunctionCallInfo functionCallInfo) { super( type, typeAnnotationMap, function, signature, argumentList, genericArgumentList, errorMode, hintList, collationList); this.functionCallInfo = functionCallInfo; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.function = this.getFunction(); builder.signature = this.getSignature(); builder.argumentList = this.getArgumentList(); builder.genericArgumentList = this.getGenericArgumentList(); builder.errorMode = this.getErrorMode(); builder.hintList = this.getHintList(); builder.collationList = this.getCollationList(); builder.functionCallInfo = this.getFunctionCallInfo(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedFunctionCallBase.Builder { protected ResolvedFunctionCallInfo functionCallInfo = new ResolvedFunctionCallInfo(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @Override @CanIgnoreReturnValue public Builder setFunction(Function v) { super.setFunction(v); return this; } @Override @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { super.setSignature(v); return this; } @Override @CanIgnoreReturnValue public Builder setArgumentList(List v) { super.setArgumentList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGenericArgumentList(List v) { super.setGenericArgumentList(v); return this; } @Override @CanIgnoreReturnValue public Builder setErrorMode(ErrorMode v) { super.setErrorMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationList(List v) { super.setCollationList(v); return this; } /** * This contains optional custom information about a particular * function call. * *

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

This field is ignorable because for most types of function calls, * there is no extra information to consider besides the arguments * and other fields from ResolvedFunctionCallBase. */ @CanIgnoreReturnValue public Builder setFunctionCallInfo(ResolvedFunctionCallInfo v) { this.functionCallInfo = v; return this; } @Override public final ResolvedFunctionCall build() { validate(); return new ResolvedFunctionCall( type, typeAnnotationMap, function, signature, argumentList, genericArgumentList, errorMode, hintList, collationList, functionCallInfo); } @Override protected void validate() { super.validate(); } } public static final ResolvedFunctionCall deserialize( ResolvedFunctionCallProto proto, AbstractDeserializationHelper 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 public ResolvedFunctionCall accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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 analytic 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; /** * Holds a table subquery defined in WITH GROUP ROWS(...) that is * evaluated over the input rows of a ResolvedAggregateScan * corresponding to the current group. The function itself is * evaluated over the rows returned from the subquery. * *

The subquery should refer to a special TVF GROUP_ROWS(), which * resolves as ResolvedGroupRowsScan. The subquery will be run for * each group produced by ResolvedAggregateScan. * *

GROUP_ROWS() produces a row for each source row in the * ResolvedAggregateScan's input that matches current group. * *

The subquery cannot reference any ResolvedColumns from the outer * query except what comes in via , * and GROUP_ROWS(). * *

The subquery can return more than one column, and these columns * can be referenced by the function. * *

The subquery can be correlated. In this case the * gives the set of ResolvedColumns * from outside the subquery that are used inside. The subuery cannot * refer to correlated columns that are used as aggregation input in * the immediate outer query. The same rules apply to * as in ResolvedSubqueryExpr. */ private final ResolvedScan withGroupRowsSubquery; /** * Correlated parameters to */ private final ImmutableList withGroupRowsParameterList; ResolvedNonScalarFunctionCallBase(ResolvedNonScalarFunctionCallBaseProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); distinct = proto.getDistinct(); nullHandlingModifier = proto.getNullHandlingModifier(); if (proto.hasWithGroupRowsSubquery()) { withGroupRowsSubquery = ResolvedScan.deserialize(proto.getWithGroupRowsSubquery(), helper); } else { withGroupRowsSubquery = null; } ImmutableList.Builder withGroupRowsParameterListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getWithGroupRowsParameterListList()) { withGroupRowsParameterListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } withGroupRowsParameterList = withGroupRowsParameterListBuilder.build(); } ResolvedNonScalarFunctionCallBase( Type type, AnnotationMap typeAnnotationMap, Function function, FunctionSignature signature, ImmutableList argumentList, ImmutableList genericArgumentList, ErrorMode errorMode, ImmutableList hintList, ImmutableList collationList, boolean distinct, NullHandlingModifier nullHandlingModifier, ResolvedScan withGroupRowsSubquery, ImmutableList withGroupRowsParameterList) { super( type, typeAnnotationMap, function, signature, argumentList, genericArgumentList, errorMode, hintList, collationList); this.distinct = distinct; this.nullHandlingModifier = nullHandlingModifier; this.withGroupRowsSubquery = withGroupRowsSubquery; this.withGroupRowsParameterList = withGroupRowsParameterList; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedFunctionCallBase.Builder { protected Boolean distinct = null; protected NullHandlingModifier nullHandlingModifier = null; protected ResolvedScan withGroupRowsSubquery = null; protected ImmutableList withGroupRowsParameterList = ImmutableList.of(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @Override @CanIgnoreReturnValue public Builder setFunction(Function v) { super.setFunction(v); return this; } @Override @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { super.setSignature(v); return this; } @Override @CanIgnoreReturnValue public Builder setArgumentList(List v) { super.setArgumentList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGenericArgumentList(List v) { super.setGenericArgumentList(v); return this; } @Override @CanIgnoreReturnValue public Builder setErrorMode(ErrorMode v) { super.setErrorMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationList(List v) { super.setCollationList(v); return this; } /** * Apply DISTINCT to the stream of input values before calling * function. */ @CanIgnoreReturnValue public Builder setDistinct(boolean v) { this.distinct = v; return this; } /** * Apply IGNORE/RESPECT NULLS filtering to the stream of input * values. */ @CanIgnoreReturnValue public Builder setNullHandlingModifier(NullHandlingModifier v) { this.nullHandlingModifier = v; return this; } /** * Holds a table subquery defined in WITH GROUP ROWS(...) that is * evaluated over the input rows of a ResolvedAggregateScan * corresponding to the current group. The function itself is * evaluated over the rows returned from the subquery. * *

The subquery should refer to a special TVF GROUP_ROWS(), which * resolves as ResolvedGroupRowsScan. The subquery will be run for * each group produced by ResolvedAggregateScan. * *

GROUP_ROWS() produces a row for each source row in the * ResolvedAggregateScan's input that matches current group. * *

The subquery cannot reference any ResolvedColumns from the outer * query except what comes in via , * and GROUP_ROWS(). * *

The subquery can return more than one column, and these columns * can be referenced by the function. * *

The subquery can be correlated. In this case the * gives the set of ResolvedColumns * from outside the subquery that are used inside. The subuery cannot * refer to correlated columns that are used as aggregation input in * the immediate outer query. The same rules apply to * as in ResolvedSubqueryExpr. */ @CanIgnoreReturnValue public Builder setWithGroupRowsSubquery(ResolvedScan v) { this.withGroupRowsSubquery = v; return this; } /** * Correlated parameters to */ @CanIgnoreReturnValue public Builder setWithGroupRowsParameterList(List v) { this.withGroupRowsParameterList = ImmutableList.copyOf(v); return this; } @Override public abstract ResolvedNonScalarFunctionCallBase build(); @Override protected void validate() { super.validate(); } } public static ResolvedNonScalarFunctionCallBase deserialize( AnyResolvedNonScalarFunctionCallBaseProto proto, AbstractDeserializationHelper 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()); // withGroupRowsSubquery is an AST node. Call its serialization chain. if (this.getWithGroupRowsSubquery() != null) { AnyResolvedScanProto.Builder withGroupRowsSubqueryBuilder = AnyResolvedScanProto.newBuilder(); this.getWithGroupRowsSubquery().serialize( fileDescriptorSetsBuilder, withGroupRowsSubqueryBuilder); proto.setWithGroupRowsSubquery( withGroupRowsSubqueryBuilder.build()); } // withGroupRowsParameterList is a collection of AST nodes. Serialize each of them. ImmutableList withGroupRowsParameterLists = this.getWithGroupRowsParameterList(); for (ResolvedColumnRef element : withGroupRowsParameterLists) { ResolvedColumnRefProto.Builder withGroupRowsParameterListBuilder = ResolvedColumnRefProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, withGroupRowsParameterListBuilder); proto.addWithGroupRowsParameterList(withGroupRowsParameterListBuilder.build()); } } /** * 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; } /** * Holds a table subquery defined in WITH GROUP ROWS(...) that is * evaluated over the input rows of a ResolvedAggregateScan * corresponding to the current group. The function itself is * evaluated over the rows returned from the subquery. * *

The subquery should refer to a special TVF GROUP_ROWS(), which * resolves as ResolvedGroupRowsScan. The subquery will be run for * each group produced by ResolvedAggregateScan. * *

GROUP_ROWS() produces a row for each source row in the * ResolvedAggregateScan's input that matches current group. * *

The subquery cannot reference any ResolvedColumns from the outer * query except what comes in via , * and GROUP_ROWS(). * *

The subquery can return more than one column, and these columns * can be referenced by the function. * *

The subquery can be correlated. In this case the * gives the set of ResolvedColumns * from outside the subquery that are used inside. The subuery cannot * refer to correlated columns that are used as aggregation input in * the immediate outer query. The same rules apply to * as in ResolvedSubqueryExpr. */ public final ResolvedScan getWithGroupRowsSubquery() { return withGroupRowsSubquery; } /** * Correlated parameters to */ public final ImmutableList getWithGroupRowsParameterList() { return withGroupRowsParameterList; } @Override public abstract ResolvedNonScalarFunctionCallBase accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(withGroupRowsSubquery); visitor.descend(withGroupRowsParameterList); } public 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))); } if (withGroupRowsSubquery != null) { fields.add(new DebugStringField("with_group_rows_subquery", withGroupRowsSubquery)); } if (!withGroupRowsParameterList.isEmpty()) { fields.add(new DebugStringField("with_group_rows_parameter_list", withGroupRowsParameterList)); } } } /** * An aggregate function call. The signature always has mode AGGREGATE. * *

FEATURE_V_1_4_MULTILEVEL_AGGREGATION enables multi-level aggregate * expressions (e.g. 'SUM(AVG(1 + X) GROUP BY key)' ). The GROUP BY modifier * within an aggregate function body indicates the presence of a multi-level * aggregate expression. * *

`group_by_aggregate_list` can only be present if `group_by_list` is * present. `group_by_list` and `group_by_aggregate_list` are mutually * exclusive with `having_modifier`. * *

If `group_by_list` is empty, then standard column visibility rules apply * (i.e. columns supplied by input scan to the enclosing AggregateScan are * visible to argument expressions and aggregate function modifiers, as are * correlated columns). * *

If `group_by_list` is non-empty, the initial aggregation is applied first, * computing the aggregate and grouping columns in `group_by_aggregate_list` * `group_by_list`. Only these computed columns (plus correlated columns) * are visible to argument expressions and aggregate function modifiers * (e.g. DISTINCT, IGNORE / RESPECT NULLS, LIMIT, ORDER BY). These * modifiers are applied on the output rows from the initial aggregation, * as input to the final aggregation. */ 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; /** * Group the stream of input values by columns in this list, and * compute the aggregates defined in `group_by_aggregate_list`. * Used only for multi-level aggregation, when * FEATURE_V_1_4_MULTILEVEL_AGGREGATION is enabled. */ private final ImmutableList groupByList; /** * Aggregate columns to compute over the grouping keys defined in * `group_by_list`. Used only for multi-level aggregation, when * FEATURE_V_1_4_MULTILEVEL_AGGREGATION is enabled. */ private final ImmutableList groupByAggregateList; ResolvedAggregateFunctionCall(ResolvedAggregateFunctionCallProto proto, AbstractDeserializationHelper 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()); ImmutableList.Builder groupByListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getGroupByListList()) { groupByListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } groupByList = groupByListBuilder.build(); ImmutableList.Builder groupByAggregateListBuilder = ImmutableList.builder(); for (AnyResolvedComputedColumnBaseProto element : proto.getGroupByAggregateListList()) { groupByAggregateListBuilder .add(ResolvedComputedColumnBase.deserialize(element, helper)); } groupByAggregateList = groupByAggregateListBuilder.build(); } ResolvedAggregateFunctionCall( Type type, AnnotationMap typeAnnotationMap, Function function, FunctionSignature signature, ImmutableList argumentList, ImmutableList genericArgumentList, ErrorMode errorMode, ImmutableList hintList, ImmutableList collationList, boolean distinct, NullHandlingModifier nullHandlingModifier, ResolvedScan withGroupRowsSubquery, ImmutableList withGroupRowsParameterList, ResolvedAggregateHavingModifier havingModifier, ImmutableList orderByItemList, ResolvedExpr limit, ResolvedFunctionCallInfo functionCallInfo, ImmutableList groupByList, ImmutableList groupByAggregateList) { super( type, typeAnnotationMap, function, signature, argumentList, genericArgumentList, errorMode, hintList, collationList, distinct, nullHandlingModifier, withGroupRowsSubquery, withGroupRowsParameterList); this.havingModifier = havingModifier; this.orderByItemList = orderByItemList; this.limit = limit; this.functionCallInfo = functionCallInfo; this.groupByList = groupByList; this.groupByAggregateList = groupByAggregateList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.function = this.getFunction(); builder.signature = this.getSignature(); builder.argumentList = this.getArgumentList(); builder.genericArgumentList = this.getGenericArgumentList(); builder.errorMode = this.getErrorMode(); builder.hintList = this.getHintList(); builder.collationList = this.getCollationList(); builder.distinct = this.getDistinct(); builder.nullHandlingModifier = this.getNullHandlingModifier(); builder.withGroupRowsSubquery = this.getWithGroupRowsSubquery(); builder.withGroupRowsParameterList = this.getWithGroupRowsParameterList(); builder.havingModifier = this.getHavingModifier(); builder.orderByItemList = this.getOrderByItemList(); builder.limit = this.getLimit(); builder.functionCallInfo = this.getFunctionCallInfo(); builder.groupByList = this.getGroupByList(); builder.groupByAggregateList = this.getGroupByAggregateList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedNonScalarFunctionCallBase.Builder { protected ResolvedAggregateHavingModifier havingModifier = null; protected ImmutableList orderByItemList = null; protected ResolvedExpr limit = null; protected ResolvedFunctionCallInfo functionCallInfo = new ResolvedFunctionCallInfo(); protected ImmutableList groupByList = ImmutableList.of(); protected ImmutableList groupByAggregateList = ImmutableList.of(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @Override @CanIgnoreReturnValue public Builder setFunction(Function v) { super.setFunction(v); return this; } @Override @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { super.setSignature(v); return this; } @Override @CanIgnoreReturnValue public Builder setArgumentList(List v) { super.setArgumentList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGenericArgumentList(List v) { super.setGenericArgumentList(v); return this; } @Override @CanIgnoreReturnValue public Builder setErrorMode(ErrorMode v) { super.setErrorMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationList(List v) { super.setCollationList(v); return this; } @Override @CanIgnoreReturnValue public Builder setDistinct(boolean v) { super.setDistinct(v); return this; } @Override @CanIgnoreReturnValue public Builder setNullHandlingModifier(NullHandlingModifier v) { super.setNullHandlingModifier(v); return this; } @Override @CanIgnoreReturnValue public Builder setWithGroupRowsSubquery(ResolvedScan v) { super.setWithGroupRowsSubquery(v); return this; } @Override @CanIgnoreReturnValue public Builder setWithGroupRowsParameterList(List v) { super.setWithGroupRowsParameterList(v); return this; } /** * Apply HAVING MAX/MIN filtering to the stream of input values. */ @CanIgnoreReturnValue public Builder setHavingModifier(ResolvedAggregateHavingModifier v) { this.havingModifier = v; return this; } /** * Apply ordering to the stream of input values before calling * function. */ @CanIgnoreReturnValue public Builder setOrderByItemList(List v) { this.orderByItemList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setLimit(ResolvedExpr v) { this.limit = v; return this; } /** * This contains optional custom information about a particular * function call. Functions may introduce subclasses of this class to * add custom information as needed on a per-function basis. * *

This field is ignorable because for most types of function calls, * there is no extra information to consider besides the arguments * and other fields from ResolvedFunctionCallBase. However, for * example, the TemplateSQLFunction in * zetasql/public/templated_sql_function.h defines the * TemplatedSQLFunctionCall subclass which includes the * fully-resolved function body in context of the actual concrete * types of the arguments provided to the function call. */ @CanIgnoreReturnValue public Builder setFunctionCallInfo(ResolvedFunctionCallInfo v) { this.functionCallInfo = v; return this; } /** * Group the stream of input values by columns in this list, and * compute the aggregates defined in `group_by_aggregate_list`. * Used only for multi-level aggregation, when * FEATURE_V_1_4_MULTILEVEL_AGGREGATION is enabled. */ @CanIgnoreReturnValue public Builder setGroupByList(List v) { this.groupByList = ImmutableList.copyOf(v); return this; } /** * Aggregate columns to compute over the grouping keys defined in * `group_by_list`. Used only for multi-level aggregation, when * FEATURE_V_1_4_MULTILEVEL_AGGREGATION is enabled. */ @CanIgnoreReturnValue public Builder setGroupByAggregateList(List v) { this.groupByAggregateList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedAggregateFunctionCall build() { validate(); return new ResolvedAggregateFunctionCall( type, typeAnnotationMap, function, signature, argumentList, genericArgumentList, errorMode, hintList, collationList, distinct, nullHandlingModifier, withGroupRowsSubquery, withGroupRowsParameterList, havingModifier, orderByItemList, limit, functionCallInfo, groupByList, groupByAggregateList); } @Override protected void validate() { super.validate(); } } public static final ResolvedAggregateFunctionCall deserialize( ResolvedAggregateFunctionCallProto proto, AbstractDeserializationHelper 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)); } // 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()); } // groupByAggregateList is a collection of AST nodes. Serialize each of them. ImmutableList groupByAggregateLists = this.getGroupByAggregateList(); for (ResolvedComputedColumnBase element : groupByAggregateLists) { AnyResolvedComputedColumnBaseProto.Builder groupByAggregateListBuilder = AnyResolvedComputedColumnBaseProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, groupByAggregateListBuilder); proto.addGroupByAggregateList(groupByAggregateListBuilder.build()); } } /** * 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; } /** * Group the stream of input values by columns in this list, and * compute the aggregates defined in `group_by_aggregate_list`. * Used only for multi-level aggregation, when * FEATURE_V_1_4_MULTILEVEL_AGGREGATION is enabled. */ public final ImmutableList getGroupByList() { return groupByList; } /** * Aggregate columns to compute over the grouping keys defined in * `group_by_list`. Used only for multi-level aggregation, when * FEATURE_V_1_4_MULTILEVEL_AGGREGATION is enabled. */ public final ImmutableList getGroupByAggregateList() { return groupByAggregateList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAggregateFunctionCall accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(havingModifier); visitor.descend(orderByItemList); visitor.descend(limit); visitor.descend(groupByList); visitor.descend(groupByAggregateList); } public 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))); } if (!groupByList.isEmpty()) { fields.add(new DebugStringField("group_by_list", groupByList)); } if (!groupByAggregateList.isEmpty()) { fields.add(new DebugStringField("group_by_aggregate_list", groupByAggregateList)); } } } /** * An analytic function call. The mode of the function is either AGGREGATE * or ANALYTIC. This node only ever shows up as a function call in a * ResolvedAnalyticFunctionGroup::analytic_function_list. Its associated * window is not under this node but as a sibling of its parent node. * *

can be NULL. */ public static final class ResolvedAnalyticFunctionCall extends ResolvedNonScalarFunctionCallBase { private final ResolvedWindowFrame windowFrame; ResolvedAnalyticFunctionCall(ResolvedAnalyticFunctionCallProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasWindowFrame()) { windowFrame = ResolvedWindowFrame.deserialize(proto.getWindowFrame(), helper); } else { windowFrame = null; } } ResolvedAnalyticFunctionCall( Type type, AnnotationMap typeAnnotationMap, Function function, FunctionSignature signature, ImmutableList argumentList, ImmutableList genericArgumentList, ErrorMode errorMode, ImmutableList hintList, ImmutableList collationList, boolean distinct, NullHandlingModifier nullHandlingModifier, ResolvedScan withGroupRowsSubquery, ImmutableList withGroupRowsParameterList, ResolvedWindowFrame windowFrame) { super( type, typeAnnotationMap, function, signature, argumentList, genericArgumentList, errorMode, hintList, collationList, distinct, nullHandlingModifier, withGroupRowsSubquery, withGroupRowsParameterList); this.windowFrame = windowFrame; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.function = this.getFunction(); builder.signature = this.getSignature(); builder.argumentList = this.getArgumentList(); builder.genericArgumentList = this.getGenericArgumentList(); builder.errorMode = this.getErrorMode(); builder.hintList = this.getHintList(); builder.collationList = this.getCollationList(); builder.distinct = this.getDistinct(); builder.nullHandlingModifier = this.getNullHandlingModifier(); builder.withGroupRowsSubquery = this.getWithGroupRowsSubquery(); builder.withGroupRowsParameterList = this.getWithGroupRowsParameterList(); builder.windowFrame = this.getWindowFrame(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedNonScalarFunctionCallBase.Builder { protected ResolvedWindowFrame windowFrame = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @Override @CanIgnoreReturnValue public Builder setFunction(Function v) { super.setFunction(v); return this; } @Override @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { super.setSignature(v); return this; } @Override @CanIgnoreReturnValue public Builder setArgumentList(List v) { super.setArgumentList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGenericArgumentList(List v) { super.setGenericArgumentList(v); return this; } @Override @CanIgnoreReturnValue public Builder setErrorMode(ErrorMode v) { super.setErrorMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationList(List v) { super.setCollationList(v); return this; } @Override @CanIgnoreReturnValue public Builder setDistinct(boolean v) { super.setDistinct(v); return this; } @Override @CanIgnoreReturnValue public Builder setNullHandlingModifier(NullHandlingModifier v) { super.setNullHandlingModifier(v); return this; } @Override @CanIgnoreReturnValue public Builder setWithGroupRowsSubquery(ResolvedScan v) { super.setWithGroupRowsSubquery(v); return this; } @Override @CanIgnoreReturnValue public Builder setWithGroupRowsParameterList(List v) { super.setWithGroupRowsParameterList(v); return this; } @CanIgnoreReturnValue public Builder setWindowFrame(ResolvedWindowFrame v) { this.windowFrame = v; Preconditions.checkNotNull(v, "windowFrame must not be null"); return this; } @Override public final ResolvedAnalyticFunctionCall build() { validate(); return new ResolvedAnalyticFunctionCall( type, typeAnnotationMap, function, signature, argumentList, genericArgumentList, errorMode, hintList, collationList, distinct, nullHandlingModifier, withGroupRowsSubquery, withGroupRowsParameterList, windowFrame); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( windowFrame != null, "windowFrame must be set"); } } public static final ResolvedAnalyticFunctionCall deserialize( ResolvedAnalyticFunctionCallProto proto, AbstractDeserializationHelper 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 public ResolvedAnalyticFunctionCall accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(windowFrame); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (windowFrame != null) { fields.add(new DebugStringField("window_frame", windowFrame)); } } } /** * Describes a leaf extended cast of ResolvedExtendedCast. See the comment * for element_list field of ResolvedExtendedCast for more details. */ public static final class ResolvedExtendedCastElement extends ResolvedArgument { private final Type fromType; private final Type toType; private final Function function; ResolvedExtendedCastElement(ResolvedExtendedCastElementProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); fromType = helper.deserialize(proto.getFromType()); toType = helper.deserialize(proto.getToType()); function = helper.deserialize(proto.getFunction()); } ResolvedExtendedCastElement( Type fromType, Type toType, Function function) { super(); this.fromType = fromType; this.toType = toType; this.function = function; } @Override public Builder toBuilder() { Builder builder = builder(); builder.fromType = this.getFromType(); builder.toType = this.getToType(); builder.function = this.getFunction(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected Type fromType = null; protected Type toType = null; protected Function function = null; private Builder() {} @CanIgnoreReturnValue public Builder setFromType(Type v) { this.fromType = v; return this; } @CanIgnoreReturnValue public Builder setToType(Type v) { this.toType = v; return this; } @CanIgnoreReturnValue public Builder setFunction(Function v) { this.function = v; return this; } @Override public final ResolvedExtendedCastElement build() { validate(); return new ResolvedExtendedCastElement( fromType, toType, function); } @Override protected void validate() { super.validate(); } } public static final ResolvedExtendedCastElement deserialize( ResolvedExtendedCastElementProto proto, AbstractDeserializationHelper helper) { return new ResolvedExtendedCastElement(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXTENDED_CAST_ELEMENT; } @Override public final String nodeKindString() { return "ExtendedCastElement"; } /** * 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(); ResolvedExtendedCastElementProto.Builder childBuilder = ResolvedExtendedCastElementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExtendedCastElementNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExtendedCastElementProto.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, ResolvedExtendedCastElementProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // fromType is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getFromType() != null) { proto.setFromType( ResolvedNodes.serialize(this.getFromType(), fileDescriptorSetsBuilder)); } // toType is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getToType() != null) { proto.setToType( ResolvedNodes.serialize(this.getToType(), fileDescriptorSetsBuilder)); } // 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)); } } public final Type getFromType() { return fromType; } public final Type getToType() { return toType; } public final Function getFunction() { return function; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedExtendedCastElement accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * Describes overall cast operation between two values where at least one * value's type is or contains an extended type (e.g. on a struct field). */ public static final class ResolvedExtendedCast extends ResolvedArgument { /** * Stores the list of leaf extended casts required as elements of * this cast. Each element is a cast where at least one of the input * or output is an extended type. For structs or arrays, the elements * will be casts for the field or element types. For structs, there * can be multiple cast elements (one for each distinct pair of field * types). For non-struct types, there will be just a single element. */ private final ImmutableList elementList; ResolvedExtendedCast(ResolvedExtendedCastProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder elementListBuilder = ImmutableList.builder(); for (ResolvedExtendedCastElementProto element : proto.getElementListList()) { elementListBuilder .add(ResolvedExtendedCastElement.deserialize(element, helper)); } elementList = elementListBuilder.build(); } ResolvedExtendedCast( ImmutableList elementList) { super(); this.elementList = elementList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.elementList = this.getElementList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList elementList = null; private Builder() {} /** * Stores the list of leaf extended casts required as elements of * this cast. Each element is a cast where at least one of the input * or output is an extended type. For structs or arrays, the elements * will be casts for the field or element types. For structs, there * can be multiple cast elements (one for each distinct pair of field * types). For non-struct types, there will be just a single element. */ @CanIgnoreReturnValue public Builder setElementList(List v) { this.elementList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedExtendedCast build() { validate(); return new ResolvedExtendedCast( elementList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( elementList != null, "elementList must be set"); } } public static final ResolvedExtendedCast deserialize( ResolvedExtendedCastProto proto, AbstractDeserializationHelper helper) { return new ResolvedExtendedCast(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXTENDED_CAST; } @Override public final String nodeKindString() { return "ExtendedCast"; } /** * 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(); ResolvedExtendedCastProto.Builder childBuilder = ResolvedExtendedCastProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExtendedCastNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExtendedCastProto.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, ResolvedExtendedCastProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // elementList is a collection of AST nodes. Serialize each of them. ImmutableList elementLists = this.getElementList(); for (ResolvedExtendedCastElement element : elementLists) { ResolvedExtendedCastElementProto.Builder elementListBuilder = ResolvedExtendedCastElementProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, elementListBuilder); proto.addElementList(elementListBuilder.build()); } } /** * Stores the list of leaf extended casts required as elements of * this cast. Each element is a cast where at least one of the input * or output is an extended type. For structs or arrays, the elements * will be casts for the field or element types. For structs, there * can be multiple cast elements (one for each distinct pair of field * types). For non-struct types, there will be just a single element. */ public final ImmutableList getElementList() { return elementList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedExtendedCast accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(elementList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!elementList.isEmpty()) { fields.add(new DebugStringField("element_list", elementList)); } } } /** * 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; /** * If at least one of types involved in this cast is or contains an * extended (TYPE_EXTENDED) type, this field contains information * necessary to execute this cast. */ private final ResolvedExtendedCast extendedCast; /** * The format string specified by the optional FORMAT clause. It is * nullptr when the clause does not exist. */ private final ResolvedExpr format; /** * The time zone expression by the optional AT TIME ZONE clause. It * is nullptr when the clause does not exist. */ private final ResolvedExpr timeZone; /** * Contains the TypeModifiers object which wraps all modifiers * following the type name in a type string (e.g. type parameters, * collation) in a cast. If there are no type modifiers specified, * this object will be empty. * *

Type parameters can be specified inside parentheses following the * type name (e.g. STRING(2)). If specified, the result of the cast * should conform to the type parameters. Engines are expected to * enforce type parameter constraints by erroring out or truncating * the cast result, depending on the output type. See * (broken link) for more details. * *

For example: * CAST("ABC" as STRING(2)) should error out * CAST(1234 as NUMERIC(2)) should error out * CAST(1.234 as NUMERIC(2,1)) should return a NumericValue of 1.2 * *

Collation can be specified with the COLLATE keyword on a string * type, e.g. STRING COLLATE 'und:ci'. If specified, the * of the ResolvedCast node will have equal * collation annotations. See * (broken link) for more details. * *

For example: * CAST("abc" AS STRING COLLATE "und:ci") should return value "abc" * in STRING type with collation "und:ci". * CAST(["abc"] AS ARRAY) should return * the array ["abc"] with collation "und:ci" at the element type. */ private final TypeModifiers typeModifiers; ResolvedCast(ResolvedCastProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } returnNullOnError = proto.getReturnNullOnError(); if (proto.hasExtendedCast()) { extendedCast = ResolvedExtendedCast.deserialize(proto.getExtendedCast(), helper); } else { extendedCast = null; } if (proto.hasFormat()) { format = ResolvedExpr.deserialize(proto.getFormat(), helper); } else { format = null; } if (proto.hasTimeZone()) { timeZone = ResolvedExpr.deserialize(proto.getTimeZone(), helper); } else { timeZone = null; } typeModifiers = helper.deserialize(proto.getTypeModifiers()); } ResolvedCast( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr expr, boolean returnNullOnError, ResolvedExtendedCast extendedCast, ResolvedExpr format, ResolvedExpr timeZone, TypeModifiers typeModifiers) { super( type, typeAnnotationMap); this.expr = expr; this.returnNullOnError = returnNullOnError; this.extendedCast = extendedCast; this.format = format; this.timeZone = timeZone; this.typeModifiers = typeModifiers; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.expr = this.getExpr(); builder.returnNullOnError = this.getReturnNullOnError(); builder.extendedCast = this.getExtendedCast(); builder.format = this.getFormat(); builder.timeZone = this.getTimeZone(); builder.typeModifiers = this.getTypeModifiers(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr expr = null; protected Boolean returnNullOnError = null; protected ResolvedExtendedCast extendedCast = null; protected ResolvedExpr format = null; protected ResolvedExpr timeZone = null; protected TypeModifiers typeModifiers = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } /** * Whether to return NULL if the cast fails. This is set to true for * SAFE_CAST. */ @CanIgnoreReturnValue public Builder setReturnNullOnError(boolean v) { this.returnNullOnError = v; return this; } /** * If at least one of types involved in this cast is or contains an * extended (TYPE_EXTENDED) type, this field contains information * necessary to execute this cast. */ @CanIgnoreReturnValue public Builder setExtendedCast(ResolvedExtendedCast v) { this.extendedCast = v; return this; } /** * The format string specified by the optional FORMAT clause. It is * nullptr when the clause does not exist. */ @CanIgnoreReturnValue public Builder setFormat(ResolvedExpr v) { this.format = v; return this; } /** * The time zone expression by the optional AT TIME ZONE clause. It * is nullptr when the clause does not exist. */ @CanIgnoreReturnValue public Builder setTimeZone(ResolvedExpr v) { this.timeZone = v; return this; } /** * Contains the TypeModifiers object which wraps all modifiers * following the type name in a type string (e.g. type parameters, * collation) in a cast. If there are no type modifiers specified, * this object will be empty. * *

Type parameters can be specified inside parentheses following the * type name (e.g. STRING(2)). If specified, the result of the cast * should conform to the type parameters. Engines are expected to * enforce type parameter constraints by erroring out or truncating * the cast result, depending on the output type. See * (broken link) for more details. * *

For example: * CAST("ABC" as STRING(2)) should error out * CAST(1234 as NUMERIC(2)) should error out * CAST(1.234 as NUMERIC(2,1)) should return a NumericValue of 1.2 * *

Collation can be specified with the COLLATE keyword on a string * type, e.g. STRING COLLATE 'und:ci'. If specified, the * of the ResolvedCast node will have equal * collation annotations. See * (broken link) for more details. * *

For example: * CAST("abc" AS STRING COLLATE "und:ci") should return value "abc" * in STRING type with collation "und:ci". * CAST(["abc"] AS ARRAY) should return * the array ["abc"] with collation "und:ci" at the element type. */ @CanIgnoreReturnValue public Builder setTypeModifiers(TypeModifiers v) { this.typeModifiers = v; return this; } @Override public final ResolvedCast build() { validate(); return new ResolvedCast( type, typeAnnotationMap, expr, returnNullOnError, extendedCast, format, timeZone, typeModifiers); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); } } public static final ResolvedCast deserialize( ResolvedCastProto proto, AbstractDeserializationHelper 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()); // extendedCast is an AST node. Call its serialization chain. if (this.getExtendedCast() != null) { ResolvedExtendedCastProto.Builder extendedCastBuilder = ResolvedExtendedCastProto.newBuilder(); this.getExtendedCast().serialize( fileDescriptorSetsBuilder, extendedCastBuilder); proto.setExtendedCast( extendedCastBuilder.build()); } // format is an AST node. Call its serialization chain. if (this.getFormat() != null) { AnyResolvedExprProto.Builder formatBuilder = AnyResolvedExprProto.newBuilder(); this.getFormat().serialize( fileDescriptorSetsBuilder, formatBuilder); proto.setFormat( formatBuilder.build()); } // timeZone is an AST node. Call its serialization chain. if (this.getTimeZone() != null) { AnyResolvedExprProto.Builder timeZoneBuilder = AnyResolvedExprProto.newBuilder(); this.getTimeZone().serialize( fileDescriptorSetsBuilder, timeZoneBuilder); proto.setTimeZone( timeZoneBuilder.build()); } // typeModifiers is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getTypeModifiers() != null) { proto.setTypeModifiers( ResolvedNodes.serialize(this.getTypeModifiers(), fileDescriptorSetsBuilder)); } } 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; } /** * If at least one of types involved in this cast is or contains an * extended (TYPE_EXTENDED) type, this field contains information * necessary to execute this cast. */ public final ResolvedExtendedCast getExtendedCast() { return extendedCast; } /** * The format string specified by the optional FORMAT clause. It is * nullptr when the clause does not exist. */ public final ResolvedExpr getFormat() { return format; } /** * The time zone expression by the optional AT TIME ZONE clause. It * is nullptr when the clause does not exist. */ public final ResolvedExpr getTimeZone() { return timeZone; } /** * Contains the TypeModifiers object which wraps all modifiers * following the type name in a type string (e.g. type parameters, * collation) in a cast. If there are no type modifiers specified, * this object will be empty. * *

Type parameters can be specified inside parentheses following the * type name (e.g. STRING(2)). If specified, the result of the cast * should conform to the type parameters. Engines are expected to * enforce type parameter constraints by erroring out or truncating * the cast result, depending on the output type. See * (broken link) for more details. * *

For example: * CAST("ABC" as STRING(2)) should error out * CAST(1234 as NUMERIC(2)) should error out * CAST(1.234 as NUMERIC(2,1)) should return a NumericValue of 1.2 * *

Collation can be specified with the COLLATE keyword on a string * type, e.g. STRING COLLATE 'und:ci'. If specified, the * of the ResolvedCast node will have equal * collation annotations. See * (broken link) for more details. * *

For example: * CAST("abc" AS STRING COLLATE "und:ci") should return value "abc" * in STRING type with collation "und:ci". * CAST(["abc"] AS ARRAY) should return * the array ["abc"] with collation "und:ci" at the element type. */ public final TypeModifiers getTypeModifiers() { return typeModifiers; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCast accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); visitor.descend(extendedCast); visitor.descend(format); visitor.descend(timeZone); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * Construct a struct value. is always a StructType. * matches 1:1 with the fields in position-wise. * Each field's type will match the corresponding field in . */ public static final class ResolvedMakeStruct extends ResolvedExpr { private final ImmutableList fieldList; ResolvedMakeStruct(ResolvedMakeStructProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder fieldListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getFieldListList()) { fieldListBuilder .add(ResolvedExpr.deserialize(element, helper)); } fieldList = fieldListBuilder.build(); } ResolvedMakeStruct( Type type, AnnotationMap typeAnnotationMap, ImmutableList fieldList) { super( type, typeAnnotationMap); this.fieldList = fieldList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.fieldList = this.getFieldList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ImmutableList fieldList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setFieldList(List v) { this.fieldList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedMakeStruct build() { validate(); return new ResolvedMakeStruct( type, typeAnnotationMap, fieldList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( fieldList != null, "fieldList must be set"); } } public static final ResolvedMakeStruct deserialize( ResolvedMakeStructProto proto, AbstractDeserializationHelper 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 public ResolvedMakeStruct accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(fieldList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!fieldList.isEmpty()) { fields.add(new DebugStringField("field_list", fieldList)); } } } /** * Construct a proto value. is always a ProtoType. * is a vector of (FieldDescriptor, expr) pairs to write. * will contain all required fields, and no duplicate fields. */ public static final class ResolvedMakeProto extends ResolvedExpr { private final ImmutableList fieldList; ResolvedMakeProto(ResolvedMakeProtoProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder fieldListBuilder = ImmutableList.builder(); for (ResolvedMakeProtoFieldProto element : proto.getFieldListList()) { fieldListBuilder .add(ResolvedMakeProtoField.deserialize(element, helper)); } fieldList = fieldListBuilder.build(); } ResolvedMakeProto( Type type, AnnotationMap typeAnnotationMap, ImmutableList fieldList) { super( type, typeAnnotationMap); this.fieldList = fieldList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.fieldList = this.getFieldList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ImmutableList fieldList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setFieldList(List v) { this.fieldList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedMakeProto build() { validate(); return new ResolvedMakeProto( type, typeAnnotationMap, fieldList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( fieldList != null, "fieldList must be set"); } } public static final ResolvedMakeProto deserialize( ResolvedMakeProtoProto proto, AbstractDeserializationHelper 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 public ResolvedMakeProto accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(fieldList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!fieldList.isEmpty()) { fields.add(new DebugStringField("field_list", fieldList)); } } } /** * One field assignment in a ResolvedMakeProto expression. * The type of expr will match with the zetasql type of the proto field. * The type will be an array iff the field is repeated. * *

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

If any value of cannot be written into the field, this query * should fail. */ public static final class ResolvedMakeProtoField extends ResolvedArgument { private final ZetaSQLFieldDescriptor fieldDescriptor; /** * Provides the Format annotation that should be used when building * this field. The annotation specifies both the ZetaSQL type and * the encoding format for this field. */ private final FieldFormat.Format format; private final ResolvedExpr expr; ResolvedMakeProtoField(ResolvedMakeProtoFieldProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); fieldDescriptor = helper.deserialize(proto.getFieldDescriptor()); format = proto.getFormat(); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } } ResolvedMakeProtoField( ZetaSQLFieldDescriptor fieldDescriptor, FieldFormat.Format format, ResolvedExpr expr) { super(); this.fieldDescriptor = fieldDescriptor; this.format = format; this.expr = expr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.fieldDescriptor = this.getFieldDescriptor(); builder.format = this.getFormat(); builder.expr = this.getExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ZetaSQLFieldDescriptor fieldDescriptor = null; protected FieldFormat.Format format = null; protected ResolvedExpr expr = null; private Builder() {} @CanIgnoreReturnValue public Builder setFieldDescriptor(ZetaSQLFieldDescriptor v) { this.fieldDescriptor = v; Preconditions.checkNotNull(v, "fieldDescriptor must not be null"); return this; } /** * Provides the Format annotation that should be used when building * this field. The annotation specifies both the ZetaSQL type and * the encoding format for this field. */ @CanIgnoreReturnValue public Builder setFormat(FieldFormat.Format v) { this.format = v; return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @Override public final ResolvedMakeProtoField build() { validate(); return new ResolvedMakeProtoField( fieldDescriptor, format, expr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( fieldDescriptor != null, "fieldDescriptor must be set"); Preconditions.checkArgument( expr != null, "expr must be set"); } } public static final ResolvedMakeProtoField deserialize( ResolvedMakeProtoFieldProto proto, AbstractDeserializationHelper 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 public ResolvedMakeProtoField accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public 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; /** * True if using s[OFFSET(0)] syntax rather than * specifying field name, Only for preserving user intent; no * semantic consequences */ private final boolean fieldExprIsPositional; ResolvedGetStructField(ResolvedGetStructFieldProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } fieldIdx = proto.getFieldIdx(); fieldExprIsPositional = proto.getFieldExprIsPositional(); } ResolvedGetStructField( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr expr, long fieldIdx, boolean fieldExprIsPositional) { super( type, typeAnnotationMap); this.expr = expr; this.fieldIdx = fieldIdx; this.fieldExprIsPositional = fieldExprIsPositional; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.expr = this.getExpr(); builder.fieldIdx = this.getFieldIdx(); builder.fieldExprIsPositional = this.getFieldExprIsPositional(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr expr = null; protected Long fieldIdx = null; protected boolean fieldExprIsPositional = false; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @CanIgnoreReturnValue public Builder setFieldIdx(long v) { this.fieldIdx = v; return this; } /** * True if using s[OFFSET(0)] syntax rather than * specifying field name, Only for preserving user intent; no * semantic consequences */ @CanIgnoreReturnValue public Builder setFieldExprIsPositional(boolean v) { this.fieldExprIsPositional = v; return this; } @Override public final ResolvedGetStructField build() { validate(); return new ResolvedGetStructField( type, typeAnnotationMap, expr, fieldIdx, fieldExprIsPositional); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( fieldIdx != null, "fieldIdx must be set"); } } public static final ResolvedGetStructField deserialize( ResolvedGetStructFieldProto proto, AbstractDeserializationHelper 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()); // fieldExprIsPositional is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setFieldExprIsPositional(this.getFieldExprIsPositional()); } public final ResolvedExpr getExpr() { return expr; } public final long getFieldIdx() { return fieldIdx; } /** * True if using s[OFFSET(0)] syntax rather than * specifying field name, Only for preserving user intent; no * semantic consequences */ public final boolean getFieldExprIsPositional() { return fieldExprIsPositional; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGetStructField accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public 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))); } if (!DebugStrings.isDefaultValue(fieldExprIsPositional)) { fields.add(new DebugStringField("field_expr_is_positional", DebugStrings.toStringImpl(fieldExprIsPositional))); } } } 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 * (the parent message) is NULL. Note that this does *not* affect * the return value when the extracted field itself is unset, in * which case the return value depends on the extracted field's * annotations (e.g., use_field_defaults). * *

This can only be set for non-message fields. If the field is a * proto2 field, then it must be annotated with * zetasql.use_defaults=true. This cannot be set when * is true or the field is required. */ private final boolean returnDefaultValueWhenUnset; ResolvedGetProtoField(ResolvedGetProtoFieldProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } fieldDescriptor = helper.deserialize(proto.getFieldDescriptor()); defaultValue = helper.deserialize(proto.getDefaultValue()); getHasBit = proto.getGetHasBit(); format = proto.getFormat(); returnDefaultValueWhenUnset = proto.getReturnDefaultValueWhenUnset(); } ResolvedGetProtoField( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr expr, ZetaSQLFieldDescriptor fieldDescriptor, Value defaultValue, boolean getHasBit, FieldFormat.Format format, boolean returnDefaultValueWhenUnset) { super( type, typeAnnotationMap); this.expr = expr; this.fieldDescriptor = fieldDescriptor; this.defaultValue = defaultValue; this.getHasBit = getHasBit; this.format = format; this.returnDefaultValueWhenUnset = returnDefaultValueWhenUnset; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.expr = this.getExpr(); builder.fieldDescriptor = this.getFieldDescriptor(); builder.defaultValue = this.getDefaultValue(); builder.getHasBit = this.getGetHasBit(); builder.format = this.getFormat(); builder.returnDefaultValueWhenUnset = this.getReturnDefaultValueWhenUnset(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr expr = null; protected ZetaSQLFieldDescriptor fieldDescriptor = null; protected Value defaultValue = null; protected Boolean getHasBit = null; protected FieldFormat.Format format = null; protected Boolean returnDefaultValueWhenUnset = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } /** * The proto2 FieldDescriptor to extract. This provides the tag * number and wire type. Additional decoding may be necessary if any * of the other modifiers below are set. Consumers should use those * ZetaSQL-computed modifiers rather than examining field * annotations directly. * *

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

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

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

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

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

TODO Make un-ignorable after clients migrate to start * using it. */ @CanIgnoreReturnValue public Builder setDefaultValue(Value v) { this.defaultValue = v; return this; } /** * Indicates whether to return a bool indicating if a value was * present, rather than return the value (or NULL). Never set for * repeated fields. This field cannot be set if * is true, and vice versa. * Expression type will be BOOL. */ @CanIgnoreReturnValue public Builder setGetHasBit(boolean v) { this.getHasBit = v; return this; } /** * Provides the Format annotation that should be used when reading * this field. The annotation specifies both the ZetaSQL type and * the encoding format for this field. This cannot be set when * get_has_bit is true. */ @CanIgnoreReturnValue public Builder setFormat(FieldFormat.Format v) { this.format = v; return this; } /** * Indicates that the default value should be returned if * (the parent message) is NULL. Note that this does *not* affect * the return value when the extracted field itself is unset, in * which case the return value depends on the extracted field's * annotations (e.g., use_field_defaults). * *

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. */ @CanIgnoreReturnValue public Builder setReturnDefaultValueWhenUnset(boolean v) { this.returnDefaultValueWhenUnset = v; return this; } @Override public final ResolvedGetProtoField build() { validate(); return new ResolvedGetProtoField( type, typeAnnotationMap, expr, fieldDescriptor, defaultValue, getHasBit, format, returnDefaultValueWhenUnset); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( fieldDescriptor != null, "fieldDescriptor must be set"); } } public static final ResolvedGetProtoField deserialize( ResolvedGetProtoFieldProto proto, AbstractDeserializationHelper 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 * (the parent message) is NULL. Note that this does *not* affect * the return value when the extracted field itself is unset, in * which case the return value depends on the extracted field's * annotations (e.g., use_field_defaults). * *

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 public ResolvedGetProtoField accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public 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))); } } } /** * Get the field from , which has a JSON type. */ public static final class ResolvedGetJsonField extends ResolvedExpr { private final ResolvedExpr expr; private final String fieldName; ResolvedGetJsonField(ResolvedGetJsonFieldProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } fieldName = proto.getFieldName(); } ResolvedGetJsonField( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr expr, String fieldName) { super( type, typeAnnotationMap); this.expr = expr; this.fieldName = fieldName; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.expr = this.getExpr(); builder.fieldName = this.getFieldName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr expr = null; protected String fieldName = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @CanIgnoreReturnValue public Builder setFieldName(String v) { this.fieldName = v; Preconditions.checkNotNull(v, "fieldName must not be null"); return this; } @Override public final ResolvedGetJsonField build() { validate(); return new ResolvedGetJsonField( type, typeAnnotationMap, expr, fieldName); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( fieldName != null, "fieldName must be set"); } } public static final ResolvedGetJsonField deserialize( ResolvedGetJsonFieldProto proto, AbstractDeserializationHelper helper) { return new ResolvedGetJsonField(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GET_JSON_FIELD; } @Override public final String nodeKindString() { return "GetJsonField"; } /** * 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(); ResolvedGetJsonFieldProto.Builder childBuilder = ResolvedGetJsonFieldProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGetJsonFieldNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGetJsonFieldProto.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, ResolvedGetJsonFieldProto.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()); } // fieldName is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setFieldName(this.getFieldName()); } public final ResolvedExpr getExpr() { return expr; } public final String getFieldName() { return fieldName; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGetJsonField accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } { fields.add(new DebugStringField("field_name", DebugStrings.toStringImpl(fieldName))); } } } /** * Constructs an initial input ARRAY from expr. For each get_field_list * expr, we evaluate the expression once with each array input element and * use the output as a new array of inputs for the next get_field_list expr. * If the result of a single expr is an array, we add each element from that * array as input to the next step instead of adding the array itself. * *

The array elements are evaluated and kept in order. For example, if only * expr is an array, the result will be equivalent to that array having the * get_field_list evaluated on each array element retaining order. */ public static final class ResolvedFlatten extends ResolvedExpr { private final ResolvedExpr expr; /** * List of 'get' fields to evaluate in order (0 or more struct get * fields followed by 0 or more proto or json get fields) starting * from expr. Each get is evaluated N times where N is the number of * array elements from the previous get (or expr for the first * expression) generated. * *

The 'get' fields may either be a ResolvedGet*Field or an array * offset function around a ResolvedGet*Field. */ private final ImmutableList getFieldList; ResolvedFlatten(ResolvedFlattenProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } ImmutableList.Builder getFieldListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getGetFieldListList()) { getFieldListBuilder .add(ResolvedExpr.deserialize(element, helper)); } getFieldList = getFieldListBuilder.build(); } ResolvedFlatten( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr expr, ImmutableList getFieldList) { super( type, typeAnnotationMap); this.expr = expr; this.getFieldList = getFieldList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.expr = this.getExpr(); builder.getFieldList = this.getGetFieldList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr expr = null; protected ImmutableList getFieldList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } /** * List of 'get' fields to evaluate in order (0 or more struct get * fields followed by 0 or more proto or json get fields) starting * from expr. Each get is evaluated N times where N is the number of * array elements from the previous get (or expr for the first * expression) generated. * *

The 'get' fields may either be a ResolvedGet*Field or an array * offset function around a ResolvedGet*Field. */ @CanIgnoreReturnValue public Builder setGetFieldList(List v) { this.getFieldList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedFlatten build() { validate(); return new ResolvedFlatten( type, typeAnnotationMap, expr, getFieldList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( getFieldList != null, "getFieldList must be set"); } } public static final ResolvedFlatten deserialize( ResolvedFlattenProto proto, AbstractDeserializationHelper helper) { return new ResolvedFlatten(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FLATTEN; } @Override public final String nodeKindString() { return "Flatten"; } /** * 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(); ResolvedFlattenProto.Builder childBuilder = ResolvedFlattenProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFlattenNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedFlattenProto.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, ResolvedFlattenProto.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()); } // getFieldList is a collection of AST nodes. Serialize each of them. ImmutableList getFieldLists = this.getGetFieldList(); for (ResolvedExpr element : getFieldLists) { AnyResolvedExprProto.Builder getFieldListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, getFieldListBuilder); proto.addGetFieldList(getFieldListBuilder.build()); } } public final ResolvedExpr getExpr() { return expr; } /** * List of 'get' fields to evaluate in order (0 or more struct get * fields followed by 0 or more proto or json get fields) starting * from expr. Each get is evaluated N times where N is the number of * array elements from the previous get (or expr for the first * expression) generated. * *

The 'get' fields may either be a ResolvedGet*Field or an array * offset function around a ResolvedGet*Field. */ public final ImmutableList getGetFieldList() { return getFieldList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedFlatten accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); visitor.descend(getFieldList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } if (!getFieldList.isEmpty()) { fields.add(new DebugStringField("get_field_list", getFieldList)); } } } /** * Argument for a child of ResolvedFlatten. This is a placeholder to indicate * that it will be invoked once for each array element from ResolvedFlatten's * expr or previous get_field_list entry. */ public static final class ResolvedFlattenedArg extends ResolvedExpr { ResolvedFlattenedArg(ResolvedFlattenedArgProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedFlattenedArg( Type type, AnnotationMap typeAnnotationMap) { super( type, typeAnnotationMap); } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @Override public final ResolvedFlattenedArg build() { validate(); return new ResolvedFlattenedArg( type, typeAnnotationMap); } @Override protected void validate() { super.validate(); } } public static final ResolvedFlattenedArg deserialize( ResolvedFlattenedArgProto proto, AbstractDeserializationHelper helper) { return new ResolvedFlattenedArg(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FLATTENED_ARG; } @Override public final String nodeKindString() { return "FlattenedArg"; } /** * 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(); ResolvedFlattenedArgProto.Builder childBuilder = ResolvedFlattenedArgProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFlattenedArgNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedFlattenedArgProto.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, ResolvedFlattenedArgProto.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 public ResolvedFlattenedArg accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * An argument to the REPLACE_FIELDS() function which specifies a field path * and a value that this field will be set to. The field path to be modified * can be constructed through the and * fields. These vectors correspond to field paths in a STRUCT and PROTO, * respectively. At least one of these vectors must be non-empty. * *

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

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

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

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

If is NULL, the field will be unset. If * is a required field, the engine must return an error if it is set * to NULL. */ private final ResolvedExpr expr; /** * A vector of integers that denotes the path to a struct field that * will be modified. The integer values in this vector correspond to * field positions (0-based) in a STRUCT. If * is also non-empty, then the field corresponding to the last index * in this vector should be of proto type. */ private final ImmutableList structIndexPath; /** * A vector of FieldDescriptors that denotes the path to a proto * field that will be modified. If is also * non-empty, then the first element in this vector should be a * subfield of the proto corresponding to the last element in * . */ private final ImmutableList protoFieldPath; ResolvedReplaceFieldItem(ResolvedReplaceFieldItemProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } structIndexPath = ImmutableList.copyOf(proto.getStructIndexPathList()); ImmutableList.Builder protoFieldPathBuilder = ImmutableList.builder(); for (FieldDescriptorRefProto element : proto.getProtoFieldPathList()) { protoFieldPathBuilder.add(helper.deserialize(element)); } protoFieldPath = protoFieldPathBuilder.build(); } ResolvedReplaceFieldItem( ResolvedExpr expr, ImmutableList structIndexPath, ImmutableList protoFieldPath) { super(); this.expr = expr; this.structIndexPath = structIndexPath; this.protoFieldPath = protoFieldPath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.expr = this.getExpr(); builder.structIndexPath = this.getStructIndexPath(); builder.protoFieldPath = this.getProtoFieldPath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr expr = null; protected ImmutableList structIndexPath = null; protected ImmutableList protoFieldPath = null; private Builder() {} /** * The value that the final field in will be set * to. * *

If is NULL, the field will be unset. If * is a required field, the engine must return an error if it is set * to NULL. */ @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } /** * A vector of integers that denotes the path to a struct field that * will be modified. The integer values in this vector correspond to * field positions (0-based) in a STRUCT. If * is also non-empty, then the field corresponding to the last index * in this vector should be of proto type. */ @CanIgnoreReturnValue public Builder setStructIndexPath(List v) { this.structIndexPath = ImmutableList.copyOf(v); return this; } /** * A vector of FieldDescriptors that denotes the path to a proto * field that will be modified. If is also * non-empty, then the first element in this vector should be a * subfield of the proto corresponding to the last element in * . */ @CanIgnoreReturnValue public Builder setProtoFieldPath(List v) { this.protoFieldPath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedReplaceFieldItem build() { validate(); return new ResolvedReplaceFieldItem( expr, structIndexPath, protoFieldPath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); } } public static final ResolvedReplaceFieldItem deserialize( ResolvedReplaceFieldItemProto proto, AbstractDeserializationHelper 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 public ResolvedReplaceFieldItem accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } if (!DebugStrings.isDefaultValue(structIndexPath)) { fields.add(new DebugStringField("struct_index_path", DebugStrings.toStringCommaSeparatedForInt(structIndexPath))); } if (!DebugStrings.isDefaultValue(protoFieldPath)) { fields.add(new DebugStringField("proto_field_path", DebugStrings.toStringPeriodSeparatedForFieldDescriptors(protoFieldPath))); } } } /** * Represents a call to the REPLACE_FIELDS() function. This function * can be used to copy a proto or struct, modify a few fields and * output the resulting proto or struct. The SQL syntax for this * function is REPLACE_FIELDS(, ). * *

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

Engines must check at evaluation time that the modifications in * obey the following rules * regarding updating protos in ZetaSQL: * - Modifying a subfield of a NULL-valued proto-valued field is an * error. * - Clearing a required field or subfield is an error. */ private final ImmutableList replaceFieldItemList; ResolvedReplaceField(ResolvedReplaceFieldProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } ImmutableList.Builder replaceFieldItemListBuilder = ImmutableList.builder(); for (ResolvedReplaceFieldItemProto element : proto.getReplaceFieldItemListList()) { replaceFieldItemListBuilder .add(ResolvedReplaceFieldItem.deserialize(element, helper)); } replaceFieldItemList = replaceFieldItemListBuilder.build(); } ResolvedReplaceField( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr expr, ImmutableList replaceFieldItemList) { super( type, typeAnnotationMap); this.expr = expr; this.replaceFieldItemList = replaceFieldItemList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.expr = this.getExpr(); builder.replaceFieldItemList = this.getReplaceFieldItemList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr expr = null; protected ImmutableList replaceFieldItemList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } /** * The proto/struct to modify. */ @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } /** * The list of field paths to be modified along with their new * values. * *

Engines must check at evaluation time that the modifications in * obey the following rules * regarding updating protos in ZetaSQL: * - Modifying a subfield of a NULL-valued proto-valued field is an * error. * - Clearing a required field or subfield is an error. */ @CanIgnoreReturnValue public Builder setReplaceFieldItemList(List v) { this.replaceFieldItemList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedReplaceField build() { validate(); return new ResolvedReplaceField( type, typeAnnotationMap, expr, replaceFieldItemList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( replaceFieldItemList != null, "replaceFieldItemList must be set"); } } public static final ResolvedReplaceField deserialize( ResolvedReplaceFieldProto proto, AbstractDeserializationHelper 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 public ResolvedReplaceField accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); visitor.descend(replaceFieldItemList); } public 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)); } } } /** * Returns a string value indicating which field of is * set in the containing proto . If none of the fields are set, an * empty string is returned. * *

See (broken link) for more detail. */ public static final class ResolvedGetProtoOneof extends ResolvedExpr { private final ResolvedExpr expr; /** * The google::protobuf::OneofDescriptor for a Oneof contained in . * This descriptor provides google::protobuf::FieldDescriptors for each of * the fields contained in the Oneof. */ private final ZetaSQLOneofDescriptor oneofDescriptor; ResolvedGetProtoOneof(ResolvedGetProtoOneofProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } oneofDescriptor = helper.deserialize(proto.getOneofDescriptor()); } ResolvedGetProtoOneof( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr expr, ZetaSQLOneofDescriptor oneofDescriptor) { super( type, typeAnnotationMap); this.expr = expr; this.oneofDescriptor = oneofDescriptor; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.expr = this.getExpr(); builder.oneofDescriptor = this.getOneofDescriptor(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr expr = null; protected ZetaSQLOneofDescriptor oneofDescriptor = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } /** * The google::protobuf::OneofDescriptor for a Oneof contained in . * This descriptor provides google::protobuf::FieldDescriptors for each of * the fields contained in the Oneof. */ @CanIgnoreReturnValue public Builder setOneofDescriptor(ZetaSQLOneofDescriptor v) { this.oneofDescriptor = v; Preconditions.checkNotNull(v, "oneofDescriptor must not be null"); return this; } @Override public final ResolvedGetProtoOneof build() { validate(); return new ResolvedGetProtoOneof( type, typeAnnotationMap, expr, oneofDescriptor); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( oneofDescriptor != null, "oneofDescriptor must be set"); } } public static final ResolvedGetProtoOneof deserialize( ResolvedGetProtoOneofProto proto, AbstractDeserializationHelper helper) { return new ResolvedGetProtoOneof(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GET_PROTO_ONEOF; } @Override public final String nodeKindString() { return "GetProtoOneof"; } /** * 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(); ResolvedGetProtoOneofProto.Builder childBuilder = ResolvedGetProtoOneofProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGetProtoOneofNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGetProtoOneofProto.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, ResolvedGetProtoOneofProto.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()); } // oneofDescriptor is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getOneofDescriptor() != null) { proto.setOneofDescriptor( ResolvedNodes.serialize(this.getOneofDescriptor(), fileDescriptorSetsBuilder)); } } public final ResolvedExpr getExpr() { return expr; } /** * The google::protobuf::OneofDescriptor for a Oneof contained in . * This descriptor provides google::protobuf::FieldDescriptors for each of * the fields contained in the Oneof. */ public final ZetaSQLOneofDescriptor getOneofDescriptor() { return oneofDescriptor; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGetProtoOneof accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } { fields.add(new DebugStringField("oneof_descriptor", DebugStrings.toStringImpl(oneofDescriptor))); } } } /** * 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. * * LIKE * Usage: [NOT] LIKE ANY|SOME|ALL ( ) * The output type is always bool. The result is true when * matches at least one row for LIKE ANY|SOME or matches all rows for * LIKE ALL, 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 relevant '$like_any' or * '$like_all' comparison function (both must be the same type of either * STRING or BYTES). NOT will be expressed as a $not FunctionCall * wrapping this SubqueryExpr. * *

The subquery for a SCALAR, ARRAY, IN or LIKE 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 subqueries of type IN or LIKE * ANY|SOME|ALL. */ private final ResolvedExpr inExpr; /** * Field is only populated for subqueries of type IN to specify the * operation collation to use to compare with the rows from * . */ private final ResolvedCollation inCollation; private final ResolvedScan subquery; /** * Note: Hints currently happen only for EXISTS, IN, or a LIKE * expression subquery but not for ARRAY or SCALAR subquery. */ private final ImmutableList hintList; ResolvedSubqueryExpr(ResolvedSubqueryExprProto proto, AbstractDeserializationHelper 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; } inCollation = helper.deserialize(proto.getInCollation()); if (proto.hasSubquery()) { subquery = ResolvedScan.deserialize(proto.getSubquery(), helper); } else { subquery = null; } ImmutableList.Builder hintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getHintListList()) { hintListBuilder .add(ResolvedOption.deserialize(element, helper)); } hintList = hintListBuilder.build(); } ResolvedSubqueryExpr( Type type, AnnotationMap typeAnnotationMap, SubqueryType subqueryType, ImmutableList parameterList, ResolvedExpr inExpr, ResolvedCollation inCollation, ResolvedScan subquery, ImmutableList hintList) { super( type, typeAnnotationMap); this.subqueryType = subqueryType; this.parameterList = parameterList; this.inExpr = inExpr; this.inCollation = inCollation; this.subquery = subquery; this.hintList = hintList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.subqueryType = this.getSubqueryType(); builder.parameterList = this.getParameterList(); builder.inExpr = this.getInExpr(); builder.inCollation = this.getInCollation(); builder.subquery = this.getSubquery(); builder.hintList = this.getHintList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected SubqueryType subqueryType = null; protected ImmutableList parameterList = null; protected ResolvedExpr inExpr = null; protected ResolvedCollation inCollation = null; protected ResolvedScan subquery = null; protected ImmutableList hintList = ImmutableList.of(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setSubqueryType(SubqueryType v) { this.subqueryType = v; Preconditions.checkNotNull(v, "subqueryType must not be null"); return this; } @CanIgnoreReturnValue public Builder setParameterList(List v) { this.parameterList = ImmutableList.copyOf(v); return this; } /** * Field is only populated for subqueries of type IN or LIKE * ANY|SOME|ALL. */ @CanIgnoreReturnValue public Builder setInExpr(ResolvedExpr v) { this.inExpr = v; return this; } /** * Field is only populated for subqueries of type IN to specify the * operation collation to use to compare with the rows from * . */ @CanIgnoreReturnValue public Builder setInCollation(ResolvedCollation v) { this.inCollation = v; return this; } @CanIgnoreReturnValue public Builder setSubquery(ResolvedScan v) { this.subquery = v; Preconditions.checkNotNull(v, "subquery must not be null"); return this; } /** * Note: Hints currently happen only for EXISTS, IN, or a LIKE * expression subquery but not for ARRAY or SCALAR subquery. */ @CanIgnoreReturnValue public Builder setHintList(List v) { this.hintList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedSubqueryExpr build() { validate(); return new ResolvedSubqueryExpr( type, typeAnnotationMap, subqueryType, parameterList, inExpr, inCollation, subquery, hintList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( subqueryType != null, "subqueryType must be set"); Preconditions.checkArgument( subquery != null, "subquery must be set"); } } public static final ResolvedSubqueryExpr deserialize( ResolvedSubqueryExprProto proto, AbstractDeserializationHelper 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()); } // inCollation is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getInCollation() != null) { proto.setInCollation( ResolvedNodes.serialize(this.getInCollation(), fileDescriptorSetsBuilder)); } // 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 subqueries of type IN or LIKE * ANY|SOME|ALL. */ public final ResolvedExpr getInExpr() { return inExpr; } /** * Field is only populated for subqueries of type IN to specify the * operation collation to use to compare with the rows from * . */ public final ResolvedCollation getInCollation() { return inCollation; } public final ResolvedScan getSubquery() { return subquery; } /** * Note: Hints currently happen only for EXISTS, IN, or a LIKE * expression subquery but not for ARRAY or SCALAR subquery. */ public final ImmutableList getHintList() { return hintList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedSubqueryExpr accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(parameterList); visitor.descend(inExpr); visitor.descend(subquery); visitor.descend(hintList); } public 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 (!DebugStrings.isDefaultValue(inCollation)) { fields.add(new DebugStringField("in_collation", DebugStrings.toStringImpl(inCollation))); } if (subquery != null) { fields.add(new DebugStringField("subquery", subquery)); } if (!hintList.isEmpty()) { fields.add(new DebugStringField("hint_list", hintList)); } } } /** * ResolvedWithExpr introduces one or more columns in that * can then be referenced inside . Each assigned expression is * evaluated once, and each reference to that column in sees the same * value even if the assigned expression is volatile. Multiple assignment * expressions are independent and cannot reference other columns in the * . * *

One or more columns that are computed before evaluating * , and which may be referenced by . * Computes the result of the ResolvedWithExpr. May reference columns * from . */ public static final class ResolvedWithExpr extends ResolvedExpr { private final ImmutableList assignmentList; private final ResolvedExpr expr; ResolvedWithExpr(ResolvedWithExprProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder assignmentListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getAssignmentListList()) { assignmentListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } assignmentList = assignmentListBuilder.build(); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } } ResolvedWithExpr( Type type, AnnotationMap typeAnnotationMap, ImmutableList assignmentList, ResolvedExpr expr) { super( type, typeAnnotationMap); this.assignmentList = assignmentList; this.expr = expr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.assignmentList = this.getAssignmentList(); builder.expr = this.getExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ImmutableList assignmentList = null; protected ResolvedExpr expr = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setAssignmentList(List v) { this.assignmentList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @Override public final ResolvedWithExpr build() { validate(); return new ResolvedWithExpr( type, typeAnnotationMap, assignmentList, expr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( assignmentList != null, "assignmentList must be set"); Preconditions.checkArgument( expr != null, "expr must be set"); } } public static final ResolvedWithExpr deserialize( ResolvedWithExprProto proto, AbstractDeserializationHelper helper) { return new ResolvedWithExpr(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_WITH_EXPR; } @Override public final String nodeKindString() { return "WithExpr"; } /** * 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(); ResolvedWithExprProto.Builder childBuilder = ResolvedWithExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedWithExprNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedWithExprProto.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, ResolvedWithExprProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // assignmentList is a collection of AST nodes. Serialize each of them. ImmutableList assignmentLists = this.getAssignmentList(); for (ResolvedComputedColumn element : assignmentLists) { ResolvedComputedColumnProto.Builder assignmentListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, assignmentListBuilder); proto.addAssignmentList(assignmentListBuilder.build()); } // 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 ImmutableList getAssignmentList() { return assignmentList; } public final ResolvedExpr getExpr() { return expr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedWithExpr accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(assignmentList); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!assignmentList.isEmpty()) { fields.add(new DebugStringField("assignment_list", assignmentList)); } if (expr != null) { fields.add(new DebugStringField("expr", expr)); } } } /** * 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 `column_list` 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 `hint_list`, storing each hint as * a ResolvedOption. * *

If `is_ordered` 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). * *

Each Scan has a `node_source` field that, if populated, represents where * the scan was from or why it was added. This is used in some cases by the * resolver, rewriters or the random query generator to record why a node was * added. The SQLBuilder may also use `node_source` to influence which query * patterns to generate. */ public static abstract class ResolvedScan extends ResolvedNode { private final ImmutableList columnList; private final ImmutableList hintList; private final boolean isOrdered; private final String nodeSource; ResolvedScan(ResolvedScanProto proto, AbstractDeserializationHelper 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(); nodeSource = proto.getNodeSource(); } ResolvedScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource) { super(); this.columnList = columnList; this.hintList = hintList; this.isOrdered = isOrdered; this.nodeSource = nodeSource; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedNode.Builder { protected ImmutableList columnList = null; protected ImmutableList hintList = ImmutableList.of(); protected boolean isOrdered = false; protected String nodeSource = ""; private Builder() {} @CanIgnoreReturnValue public Builder setColumnList(List v) { this.columnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setHintList(List v) { this.hintList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { this.isOrdered = v; return this; } @CanIgnoreReturnValue public Builder setNodeSource(String v) { this.nodeSource = v; return this; } @Override public abstract ResolvedScan build(); @Override protected void validate() { super.validate(); } } public static ResolvedScan deserialize( AnyResolvedScanProto proto, AbstractDeserializationHelper 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); case RESOLVED_RECURSIVE_REF_SCAN_NODE: return ResolvedRecursiveRefScan.deserialize( proto.getResolvedRecursiveRefScanNode(), helper); case RESOLVED_RECURSIVE_SCAN_NODE: return ResolvedRecursiveScan.deserialize( proto.getResolvedRecursiveScanNode(), helper); case RESOLVED_PIVOT_SCAN_NODE: return ResolvedPivotScan.deserialize( proto.getResolvedPivotScanNode(), helper); case RESOLVED_UNPIVOT_SCAN_NODE: return ResolvedUnpivotScan.deserialize( proto.getResolvedUnpivotScanNode(), helper); case RESOLVED_GROUP_ROWS_SCAN_NODE: return ResolvedGroupRowsScan.deserialize( proto.getResolvedGroupRowsScanNode(), helper); case RESOLVED_EXECUTE_AS_ROLE_SCAN_NODE: return ResolvedExecuteAsRoleScan.deserialize( proto.getResolvedExecuteAsRoleScanNode(), helper); case RESOLVED_GRAPH_TABLE_SCAN_NODE: return ResolvedGraphTableScan.deserialize( proto.getResolvedGraphTableScanNode(), helper); case RESOLVED_GRAPH_PATH_SCAN_BASE_NODE: return ResolvedGraphPathScanBase.deserialize( proto.getResolvedGraphPathScanBaseNode(), helper); case RESOLVED_GRAPH_SCAN_BASE_NODE: return ResolvedGraphScanBase.deserialize( proto.getResolvedGraphScanBaseNode(), helper); case RESOLVED_GRAPH_REF_SCAN_NODE: return ResolvedGraphRefScan.deserialize( proto.getResolvedGraphRefScanNode(), helper); case RESOLVED_STATIC_DESCRIBE_SCAN_NODE: return ResolvedStaticDescribeScan.deserialize( proto.getResolvedStaticDescribeScanNode(), helper); case RESOLVED_ASSERT_SCAN_NODE: return ResolvedAssertScan.deserialize( proto.getResolvedAssertScanNode(), helper); case RESOLVED_BARRIER_SCAN_NODE: return ResolvedBarrierScan.deserialize( proto.getResolvedBarrierScanNode(), helper); case RESOLVED_MATCH_RECOGNIZE_SCAN_NODE: return ResolvedMatchRecognizeScan.deserialize( proto.getResolvedMatchRecognizeScanNode(), helper); case RESOLVED_LOG_SCAN_NODE: return ResolvedLogScan.deserialize( proto.getResolvedLogScanNode(), helper); case RESOLVED_SUBPIPELINE_INPUT_SCAN_NODE: return ResolvedSubpipelineInputScan.deserialize( proto.getResolvedSubpipelineInputScanNode(), helper); case RESOLVED_PIPE_IF_SCAN_NODE: return ResolvedPipeIfScan.deserialize( proto.getResolvedPipeIfScanNode(), helper); case RESOLVED_PIPE_FORK_SCAN_NODE: return ResolvedPipeForkScan.deserialize( proto.getResolvedPipeForkScanNode(), helper); case RESOLVED_PIPE_EXPORT_DATA_SCAN_NODE: return ResolvedPipeExportDataScan.deserialize( proto.getResolvedPipeExportDataScanNode(), 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()); // nodeSource is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setNodeSource(this.getNodeSource()); } public final ImmutableList getColumnList() { return columnList; } public final ImmutableList getHintList() { return hintList; } public final boolean getIsOrdered() { return isOrdered; } public final String getNodeSource() { return nodeSource; } @Override public abstract ResolvedScan accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(hintList); } public 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))); } if (!DebugStrings.isDefaultValue(nodeSource)) { fields.add(new DebugStringField("node_source", DebugStrings.toStringImpl(nodeSource))); } } } /** * This node provides the role context for its subtree. Currently, it only * handles subtrees from inlined TVFs and VIEWs created with DEFINER rights. * Due to the lack of a ROLE catalog object, we are using the original * catalog object (VIEW or TVF) as a proxy. The engine is expected to extract * the target role of these objects. * *

In the future, when we have catalog objects for roles, this node should * be updated to attach role object, rather than the original inlined object. * *

The node's role context covers the whole subtree underneath it, except * subtrees under other nested ResolvedExecuteAsRoleScan nodes. * *

Always creates new output columns in , which map 1:1 with * the 's output columns. Most rewriters trace their columns all * the way back to the scan that defined them so this makes this node a * boundary, as desired. */ public static final class ResolvedExecuteAsRoleScan extends ResolvedScan { /** * The input scan whose subtree is to be encompassed by the current * role context. */ private final ResolvedScan inputScan; /** * The original view that was inlined. If set, then * 'original_inlined_tvf' is null. The validator checks that this * table is indeed a SqlView, not some other subclass of Table. */ private final Table originalInlinedView; /** * The original TVF that was inlined. If set, then * 'original_inlined_view' is null. */ private final TableValuedFunction originalInlinedTvf; ResolvedExecuteAsRoleScan(ResolvedExecuteAsRoleScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } originalInlinedView = helper.deserialize(proto.getOriginalInlinedView()); originalInlinedTvf = helper.deserialize(proto.getOriginalInlinedTvf()); } ResolvedExecuteAsRoleScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, Table originalInlinedView, TableValuedFunction originalInlinedTvf) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.originalInlinedView = originalInlinedView; this.originalInlinedTvf = originalInlinedTvf; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.originalInlinedView = this.getOriginalInlinedView(); builder.originalInlinedTvf = this.getOriginalInlinedTvf(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected Table originalInlinedView = null; protected TableValuedFunction originalInlinedTvf = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } /** * The input scan whose subtree is to be encompassed by the current * role context. */ @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); setIsOrdered(v.getIsOrdered()); return this; } /** * The original view that was inlined. If set, then * 'original_inlined_tvf' is null. The validator checks that this * table is indeed a SqlView, not some other subclass of Table. */ @CanIgnoreReturnValue public Builder setOriginalInlinedView(Table v) { this.originalInlinedView = v; Preconditions.checkNotNull(v, "originalInlinedView must not be null"); return this; } /** * The original TVF that was inlined. If set, then * 'original_inlined_view' is null. */ @CanIgnoreReturnValue public Builder setOriginalInlinedTvf(TableValuedFunction v) { this.originalInlinedTvf = v; Preconditions.checkNotNull(v, "originalInlinedTvf must not be null"); return this; } @Override public final ResolvedExecuteAsRoleScan build() { validate(); return new ResolvedExecuteAsRoleScan( columnList, hintList, isOrdered, nodeSource, inputScan, originalInlinedView, originalInlinedTvf); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( originalInlinedView != null, "originalInlinedView must be set"); Preconditions.checkArgument( originalInlinedTvf != null, "originalInlinedTvf must be set"); } } public static final ResolvedExecuteAsRoleScan deserialize( ResolvedExecuteAsRoleScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedExecuteAsRoleScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXECUTE_AS_ROLE_SCAN; } @Override public final String nodeKindString() { return "ExecuteAsRoleScan"; } /** * 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(); ResolvedExecuteAsRoleScanProto.Builder childBuilder = ResolvedExecuteAsRoleScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExecuteAsRoleScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExecuteAsRoleScanProto.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, ResolvedExecuteAsRoleScanProto.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()); } // originalInlinedView is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getOriginalInlinedView() != null) { proto.setOriginalInlinedView( ResolvedNodes.serialize(this.getOriginalInlinedView(), fileDescriptorSetsBuilder)); } // originalInlinedTvf is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getOriginalInlinedTvf() != null) { proto.setOriginalInlinedTvf( ResolvedNodes.serialize(this.getOriginalInlinedTvf(), fileDescriptorSetsBuilder)); } } /** * The input scan whose subtree is to be encompassed by the current * role context. */ public final ResolvedScan getInputScan() { return inputScan; } /** * The original view that was inlined. If set, then * 'original_inlined_tvf' is null. The validator checks that this * table is indeed a SqlView, not some other subclass of Table. */ public final Table getOriginalInlinedView() { return originalInlinedView; } /** * The original TVF that was inlined. If set, then * 'original_inlined_view' is null. */ public final TableValuedFunction getOriginalInlinedTvf() { return originalInlinedTvf; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedExecuteAsRoleScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } { fields.add(new DebugStringField("original_inlined_view", DebugStrings.toStringImpl(originalInlinedView))); } { fields.add(new DebugStringField("original_inlined_tvf", DebugStrings.toStringImpl(originalInlinedTvf))); } } } /** * Represents a machine learning model as a TVF argument. * is the machine learning model object known to the resolver * (usually through the catalog). */ public static final class ResolvedModel extends ResolvedArgument { private final Model model; ResolvedModel(ResolvedModelProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); model = helper.deserialize(proto.getModel()); } ResolvedModel( Model model) { super(); this.model = model; } @Override public Builder toBuilder() { Builder builder = builder(); builder.model = this.getModel(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected Model model = null; private Builder() {} @CanIgnoreReturnValue public Builder setModel(Model v) { this.model = v; Preconditions.checkNotNull(v, "model must not be null"); return this; } @Override public final ResolvedModel build() { validate(); return new ResolvedModel( model); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( model != null, "model must be set"); } } public static final ResolvedModel deserialize( ResolvedModelProto proto, AbstractDeserializationHelper 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 public ResolvedModel accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("model", DebugStrings.toStringImpl(model))); } } } /** * Represents a connection object, which encapsulates engine-specific * metadata used to connect to an external data source. */ public static final class ResolvedConnection extends ResolvedArgument { private final Connection connection; ResolvedConnection(ResolvedConnectionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); connection = helper.deserialize(proto.getConnection()); } ResolvedConnection( Connection connection) { super(); this.connection = connection; } @Override public Builder toBuilder() { Builder builder = builder(); builder.connection = this.getConnection(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected Connection connection = null; private Builder() {} @CanIgnoreReturnValue public Builder setConnection(Connection v) { this.connection = v; Preconditions.checkNotNull(v, "connection must not be null"); return this; } @Override public final ResolvedConnection build() { validate(); return new ResolvedConnection( connection); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( connection != null, "connection must be set"); } } public static final ResolvedConnection deserialize( ResolvedConnectionProto proto, AbstractDeserializationHelper helper) { return new ResolvedConnection(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CONNECTION; } @Override public final String nodeKindString() { return "Connection"; } /** * Serializes this node into a {@link AnyResolvedArgumentProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedArgumentProto.Builder builder = AnyResolvedArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedArgumentProto.Builder}. * Adds any new file descriptor sets it encounters to the {@code fileDescriptorSetsBuilder}. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, AnyResolvedArgumentProto.Builder builder) { builder.clear(); ResolvedConnectionProto.Builder childBuilder = ResolvedConnectionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedConnectionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedConnectionProto.Builder}. * Adds any new file descriptor sets it encounters to the builder. * All preexisting state in the proto builder is cleared. */ public final void serialize( FileDescriptorSetsBuilder fileDescriptorSetsBuilder, ResolvedConnectionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // connection is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getConnection() != null) { proto.setConnection( ResolvedNodes.serialize(this.getConnection(), fileDescriptorSetsBuilder)); } } public final Connection getConnection() { return connection; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedConnection accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("connection", DebugStrings.toStringImpl(connection))); } } } /** * Represents a descriptor object as a TVF argument. * A descriptor is basically a list of unresolved column names, written * DESCRIPTOR(column1, column2) * *

contains the column names. * *

If FunctionArgumentTypeOptions.get_resolve_descriptor_names_table_offset() * is true, then contains resolved columns from * the sibling ResolvedFunctionArgument of scan type, and will match * positionally with . */ public static final class ResolvedDescriptor extends ResolvedArgument { private final ImmutableList descriptorColumnList; private final ImmutableList descriptorColumnNameList; ResolvedDescriptor(ResolvedDescriptorProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder descriptorColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getDescriptorColumnListList()) { descriptorColumnListBuilder.add(helper.deserialize(element)); } descriptorColumnList = descriptorColumnListBuilder.build(); descriptorColumnNameList = ImmutableList.copyOf(proto.getDescriptorColumnNameListList()); } ResolvedDescriptor( ImmutableList descriptorColumnList, ImmutableList descriptorColumnNameList) { super(); this.descriptorColumnList = descriptorColumnList; this.descriptorColumnNameList = descriptorColumnNameList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.descriptorColumnList = this.getDescriptorColumnList(); builder.descriptorColumnNameList = this.getDescriptorColumnNameList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList descriptorColumnList = null; protected ImmutableList descriptorColumnNameList = null; private Builder() {} @CanIgnoreReturnValue public Builder setDescriptorColumnList(List v) { this.descriptorColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setDescriptorColumnNameList(List v) { this.descriptorColumnNameList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedDescriptor build() { validate(); return new ResolvedDescriptor( descriptorColumnList, descriptorColumnNameList); } @Override protected void validate() { super.validate(); } } public static final ResolvedDescriptor deserialize( ResolvedDescriptorProto proto, AbstractDeserializationHelper helper) { return new ResolvedDescriptor(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DESCRIPTOR; } @Override public final String nodeKindString() { return "Descriptor"; } /** * 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(); ResolvedDescriptorProto.Builder childBuilder = ResolvedDescriptorProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDescriptorNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDescriptorProto.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, ResolvedDescriptorProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // descriptorColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList descriptorColumnLists = this.getDescriptorColumnList(); for (ResolvedColumn element : descriptorColumnLists) { proto.addDescriptorColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // descriptorColumnNameList 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.addAllDescriptorColumnNameList(this.getDescriptorColumnNameList()); } public final ImmutableList getDescriptorColumnList() { return descriptorColumnList; } public final ImmutableList getDescriptorColumnNameList() { return descriptorColumnNameList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDescriptor accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(descriptorColumnList)) { fields.add(new DebugStringField("descriptor_column_list", DebugStrings.toStringImpl(descriptorColumnList))); } if (!DebugStrings.isDefaultValue(descriptorColumnNameList)) { fields.add(new DebugStringField("descriptor_column_name_list", DebugStrings.toStringCommaSeparated(descriptorColumnNameList))); } } } /** * Scan that produces a single row with no columns. Used for queries without * a FROM clause, where all output comes from the select list. */ public static final class ResolvedSingleRowScan extends ResolvedScan { ResolvedSingleRowScan(ResolvedSingleRowScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedSingleRowScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource) { super( columnList, hintList, isOrdered, nodeSource); } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override public final ResolvedSingleRowScan build() { validate(); return new ResolvedSingleRowScan( columnList, hintList, isOrdered, nodeSource); } @Override protected void validate() { super.validate(); } } public static final ResolvedSingleRowScan deserialize( ResolvedSingleRowScanProto proto, AbstractDeserializationHelper 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 public ResolvedSingleRowScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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. * Pruning has no effect on value tables (the value is never pruned). * *

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. * *

This list matches 1-1 with the , and * identifies the ordinal of the corresponding column in the

's * column list. * *

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 * ResolvedColumn name. This violates the ResolvedColumn contract, which * explicitly states that the ResolvedColumn name has no semantic meaning. * All code building a ResolvedTableScan should always * set_column_index_list() immediately after construction. */ public static final class ResolvedTableScan extends ResolvedScan { private final Table table; private final ResolvedExpr forSystemTimeExpr; private final ImmutableList columnIndexList; private final String alias; private final ResolvedLockMode lockMode; ResolvedTableScan(ResolvedTableScanProto proto, AbstractDeserializationHelper 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(); if (proto.hasLockMode()) { lockMode = ResolvedLockMode.deserialize(proto.getLockMode(), helper); } else { lockMode = null; } } ResolvedTableScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, Table table, ResolvedExpr forSystemTimeExpr, ImmutableList columnIndexList, String alias, ResolvedLockMode lockMode) { super( columnList, hintList, isOrdered, nodeSource); this.table = table; this.forSystemTimeExpr = forSystemTimeExpr; this.columnIndexList = columnIndexList; this.alias = alias; this.lockMode = lockMode; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.table = this.getTable(); builder.forSystemTimeExpr = this.getForSystemTimeExpr(); builder.columnIndexList = this.getColumnIndexList(); builder.alias = this.getAlias(); builder.lockMode = this.getLockMode(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected Table table = null; protected ResolvedExpr forSystemTimeExpr = null; protected ImmutableList columnIndexList = ImmutableList.of(); protected String alias = ""; protected ResolvedLockMode lockMode = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setTable(Table v) { this.table = v; Preconditions.checkNotNull(v, "table must not be null"); return this; } @CanIgnoreReturnValue public Builder setForSystemTimeExpr(ResolvedExpr v) { this.forSystemTimeExpr = v; return this; } @CanIgnoreReturnValue public Builder setColumnIndexList(List v) { this.columnIndexList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setAlias(String v) { this.alias = v; return this; } @CanIgnoreReturnValue public Builder setLockMode(ResolvedLockMode v) { this.lockMode = v; return this; } @Override public final ResolvedTableScan build() { validate(); return new ResolvedTableScan( columnList, hintList, isOrdered, nodeSource, table, forSystemTimeExpr, columnIndexList, alias, lockMode); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( table != null, "table must be set"); } } public static final ResolvedTableScan deserialize( ResolvedTableScanProto proto, AbstractDeserializationHelper 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()); // lockMode is an AST node. Call its serialization chain. if (this.getLockMode() != null) { ResolvedLockModeProto.Builder lockModeBuilder = ResolvedLockModeProto.newBuilder(); this.getLockMode().serialize( fileDescriptorSetsBuilder, lockModeBuilder); proto.setLockMode( lockModeBuilder.build()); } } public final Table getTable() { return table; } public final ResolvedExpr getForSystemTimeExpr() { return forSystemTimeExpr; } public final ImmutableList getColumnIndexList() { return columnIndexList; } public final String getAlias() { return alias; } public final ResolvedLockMode getLockMode() { return lockMode; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedTableScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(forSystemTimeExpr); visitor.descend(lockMode); } public 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))); } if (lockMode != null) { fields.add(new DebugStringField("lock_mode", lockMode)); } } } /** * 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; /** * This indicates this join was generated from syntax with USING. * The sql_builder will use this field only as a suggestion. * JOIN USING(...) syntax will be used if and only if * `has_using` is True and `join_expr` has the correct shape. * Otherwise the sql_builder will generate JOIN ON. */ private final boolean hasUsing; ResolvedJoinScan(ResolvedJoinScanProto proto, AbstractDeserializationHelper 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; } hasUsing = proto.getHasUsing(); } ResolvedJoinScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, JoinType joinType, ResolvedScan leftScan, ResolvedScan rightScan, ResolvedExpr joinExpr, boolean hasUsing) { super( columnList, hintList, isOrdered, nodeSource); this.joinType = joinType; this.leftScan = leftScan; this.rightScan = rightScan; this.joinExpr = joinExpr; this.hasUsing = hasUsing; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.joinType = this.getJoinType(); builder.leftScan = this.getLeftScan(); builder.rightScan = this.getRightScan(); builder.joinExpr = this.getJoinExpr(); builder.hasUsing = this.getHasUsing(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected JoinType joinType = null; protected ResolvedScan leftScan = null; protected ResolvedScan rightScan = null; protected ResolvedExpr joinExpr = null; protected boolean hasUsing = false; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setJoinType(JoinType v) { this.joinType = v; return this; } @CanIgnoreReturnValue public Builder setLeftScan(ResolvedScan v) { this.leftScan = v; Preconditions.checkNotNull(v, "leftScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setRightScan(ResolvedScan v) { this.rightScan = v; Preconditions.checkNotNull(v, "rightScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setJoinExpr(ResolvedExpr v) { this.joinExpr = v; return this; } /** * This indicates this join was generated from syntax with USING. * The sql_builder will use this field only as a suggestion. * JOIN USING(...) syntax will be used if and only if * `has_using` is True and `join_expr` has the correct shape. * Otherwise the sql_builder will generate JOIN ON. */ @CanIgnoreReturnValue public Builder setHasUsing(boolean v) { this.hasUsing = v; return this; } @Override public final ResolvedJoinScan build() { validate(); return new ResolvedJoinScan( columnList, hintList, isOrdered, nodeSource, joinType, leftScan, rightScan, joinExpr, hasUsing); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( leftScan != null, "leftScan must be set"); Preconditions.checkArgument( rightScan != null, "rightScan must be set"); } } public static final ResolvedJoinScan deserialize( ResolvedJoinScanProto proto, AbstractDeserializationHelper 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()); } // hasUsing is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setHasUsing(this.getHasUsing()); } public final JoinType getJoinType() { return joinType; } public final ResolvedScan getLeftScan() { return leftScan; } public final ResolvedScan getRightScan() { return rightScan; } public final ResolvedExpr getJoinExpr() { return joinExpr; } /** * This indicates this join was generated from syntax with USING. * The sql_builder will use this field only as a suggestion. * JOIN USING(...) syntax will be used if and only if * `has_using` is True and `join_expr` has the correct shape. * Otherwise the sql_builder will generate JOIN ON. */ public final boolean getHasUsing() { return hasUsing; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedJoinScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(leftScan); visitor.descend(rightScan); visitor.descend(joinExpr); } public 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)); } if (!DebugStrings.isDefaultValue(hasUsing)) { fields.add(new DebugStringField("has_using", DebugStrings.toStringImpl(hasUsing))); } } } /** * Scan one or more (N) array values produced by evaluating N expressions, * merging them positionally. Without FEATURE_V_1_4_MULTIWAY_UNNEST, it must * be exactly one array (N=1). * *

If `input_scan` is NULL, this produces one row for each array offset. * This can occur when using syntax: * UNNEST(expression [, expression [, ...]]) * *

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

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

If the array is empty (after evaluating `join_expr`), then * 1. If `is_outer` is false, the scan produces zero rows. * 2. If `is_outer` is true, the scan produces one row with N NULL values. * *

`element_column_list` are the new columns produced by this scan that store * the array element values for each row. `element_column_list` and * `array_expr_list` must have the same size N. * *

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

This node's `column_list` can have columns from `input_scan`, * `element_column_list` and `array_offset_column`. * *

`array_zip_mode` specifies the zipping behavior when there are multiple * arrays in `array_expr_list` and they have different sizes. It must be NULL * when there is only one given array. * *

The getters and setters for legacy fields `array_expr` and * `element_column` are added for backward compatibility purposes. If the * corresponding vector field has more than 1 element and only legacy * accessors are called, the field is not considered as accessed. */ public static final class ResolvedArrayScan extends ResolvedScan { private final ResolvedScan inputScan; private final ImmutableList arrayExprList; private final ImmutableList elementColumnList; private final ResolvedColumnHolder arrayOffsetColumn; private final ResolvedExpr joinExpr; private final boolean isOuter; /** * Stores a builtin ENUM ARRAY_ZIP_MODE with three possible values: * PAD, TRUNCATE or STRICT. */ private final ResolvedExpr arrayZipMode; ResolvedArrayScan(ResolvedArrayScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } ImmutableList.Builder arrayExprListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getArrayExprListList()) { arrayExprListBuilder .add(ResolvedExpr.deserialize(element, helper)); } arrayExprList = arrayExprListBuilder.build(); ImmutableList.Builder elementColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getElementColumnListList()) { elementColumnListBuilder.add(helper.deserialize(element)); } elementColumnList = elementColumnListBuilder.build(); 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(); if (proto.hasArrayZipMode()) { arrayZipMode = ResolvedExpr.deserialize(proto.getArrayZipMode(), helper); } else { arrayZipMode = null; } } ResolvedArrayScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList arrayExprList, ImmutableList elementColumnList, ResolvedColumnHolder arrayOffsetColumn, ResolvedExpr joinExpr, boolean isOuter, ResolvedExpr arrayZipMode) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.arrayExprList = arrayExprList; this.elementColumnList = elementColumnList; this.arrayOffsetColumn = arrayOffsetColumn; this.joinExpr = joinExpr; this.isOuter = isOuter; this.arrayZipMode = arrayZipMode; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.arrayExprList = this.getArrayExprList(); builder.elementColumnList = this.getElementColumnList(); builder.arrayOffsetColumn = this.getArrayOffsetColumn(); builder.joinExpr = this.getJoinExpr(); builder.isOuter = this.getIsOuter(); builder.arrayZipMode = this.getArrayZipMode(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ImmutableList arrayExprList = null; protected ImmutableList elementColumnList = null; protected ResolvedColumnHolder arrayOffsetColumn = null; protected ResolvedExpr joinExpr = null; protected Boolean isOuter = null; protected ResolvedExpr arrayZipMode = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; return this; } @CanIgnoreReturnValue public Builder setArrayExprList(List v) { this.arrayExprList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setElementColumnList(List v) { this.elementColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setArrayOffsetColumn(ResolvedColumnHolder v) { this.arrayOffsetColumn = v; return this; } @CanIgnoreReturnValue public Builder setJoinExpr(ResolvedExpr v) { this.joinExpr = v; return this; } @CanIgnoreReturnValue public Builder setIsOuter(boolean v) { this.isOuter = v; return this; } /** * Stores a builtin ENUM ARRAY_ZIP_MODE with three possible values: * PAD, TRUNCATE or STRICT. */ @CanIgnoreReturnValue public Builder setArrayZipMode(ResolvedExpr v) { this.arrayZipMode = v; return this; } @Override public final ResolvedArrayScan build() { validate(); return new ResolvedArrayScan( columnList, hintList, isOrdered, nodeSource, inputScan, arrayExprList, elementColumnList, arrayOffsetColumn, joinExpr, isOuter, arrayZipMode); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( arrayExprList != null, "arrayExprList must be set"); Preconditions.checkArgument( elementColumnList != null, "elementColumnList must be set"); } } public static final ResolvedArrayScan deserialize( ResolvedArrayScanProto proto, AbstractDeserializationHelper 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()); } // arrayExprList is a collection of AST nodes. Serialize each of them. ImmutableList arrayExprLists = this.getArrayExprList(); for (ResolvedExpr element : arrayExprLists) { AnyResolvedExprProto.Builder arrayExprListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, arrayExprListBuilder); proto.addArrayExprList(arrayExprListBuilder.build()); } // elementColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList elementColumnLists = this.getElementColumnList(); for (ResolvedColumn element : elementColumnLists) { proto.addElementColumnList(ResolvedNodes.serialize(element, 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()); // arrayZipMode is an AST node. Call its serialization chain. if (this.getArrayZipMode() != null) { AnyResolvedExprProto.Builder arrayZipModeBuilder = AnyResolvedExprProto.newBuilder(); this.getArrayZipMode().serialize( fileDescriptorSetsBuilder, arrayZipModeBuilder); proto.setArrayZipMode( arrayZipModeBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ImmutableList getArrayExprList() { return arrayExprList; } public final ImmutableList getElementColumnList() { return elementColumnList; } public final ResolvedColumnHolder getArrayOffsetColumn() { return arrayOffsetColumn; } public final ResolvedExpr getJoinExpr() { return joinExpr; } public final boolean getIsOuter() { return isOuter; } /** * Stores a builtin ENUM ARRAY_ZIP_MODE with three possible values: * PAD, TRUNCATE or STRICT. */ public final ResolvedExpr getArrayZipMode() { return arrayZipMode; } // Special override for backward compatibility purposes. public final ResolvedExpr getArrayExpr() { return getArrayExprList().get(0); } public final ResolvedColumn getElementColumn() { return getElementColumnList().get(0); } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedArrayScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(arrayExprList); visitor.descend(arrayOffsetColumn); visitor.descend(joinExpr); visitor.descend(arrayZipMode); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (!arrayExprList.isEmpty()) { fields.add(new DebugStringField("array_expr_list", arrayExprList)); } { fields.add(new DebugStringField("element_column_list", DebugStrings.toStringImpl(elementColumnList))); } 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))); } if (arrayZipMode != null) { fields.add(new DebugStringField("array_zip_mode", arrayZipMode)); } } } /** * This wrapper is used for an optional ResolvedColumn inside another node. */ public static final class ResolvedColumnHolder extends ResolvedArgument { private final ResolvedColumn column; ResolvedColumnHolder(ResolvedColumnHolderProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); column = helper.deserialize(proto.getColumn()); } ResolvedColumnHolder( ResolvedColumn column) { super(); this.column = column; } @Override public Builder toBuilder() { Builder builder = builder(); builder.column = this.getColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedColumn column = null; private Builder() {} @CanIgnoreReturnValue public Builder setColumn(ResolvedColumn v) { this.column = v; Preconditions.checkNotNull(v, "column must not be null"); return this; } @Override public final ResolvedColumnHolder build() { validate(); return new ResolvedColumnHolder( column); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( column != null, "column must be set"); } } public static final ResolvedColumnHolder deserialize( ResolvedColumnHolderProto proto, AbstractDeserializationHelper 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 public ResolvedColumnHolder accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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; ResolvedFilterScan(ResolvedFilterScanProto proto, AbstractDeserializationHelper 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; } } ResolvedFilterScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ResolvedExpr filterExpr) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.filterExpr = filterExpr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.filterExpr = this.getFilterExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ResolvedExpr filterExpr = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setFilterExpr(ResolvedExpr v) { this.filterExpr = v; Preconditions.checkNotNull(v, "filterExpr must not be null"); return this; } @Override public final ResolvedFilterScan build() { validate(); return new ResolvedFilterScan( columnList, hintList, isOrdered, nodeSource, inputScan, filterExpr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( filterExpr != null, "filterExpr must be set"); } } public static final ResolvedFilterScan deserialize( ResolvedFilterScanProto proto, AbstractDeserializationHelper 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 public ResolvedFilterScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(filterExpr); } public 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)); } } } /** * A GROUPING function call. `group_by_column` must be a column from * the `group_by_list` in `ResolvedAggregateScan`. * `output_column` is a new column of type int64. * Its output value is 0 if `group_by_column` is included in the current * grouping set, or 1 if not. */ public static final class ResolvedGroupingCall extends ResolvedArgument { private final ResolvedColumnRef groupByColumn; private final ResolvedColumn outputColumn; ResolvedGroupingCall(ResolvedGroupingCallProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasGroupByColumn()) { groupByColumn = ResolvedColumnRef.deserialize(proto.getGroupByColumn(), helper); } else { groupByColumn = null; } outputColumn = helper.deserialize(proto.getOutputColumn()); } ResolvedGroupingCall( ResolvedColumnRef groupByColumn, ResolvedColumn outputColumn) { super(); this.groupByColumn = groupByColumn; this.outputColumn = outputColumn; } @Override public Builder toBuilder() { Builder builder = builder(); builder.groupByColumn = this.getGroupByColumn(); builder.outputColumn = this.getOutputColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedColumnRef groupByColumn = null; protected ResolvedColumn outputColumn = null; private Builder() {} @CanIgnoreReturnValue public Builder setGroupByColumn(ResolvedColumnRef v) { this.groupByColumn = v; Preconditions.checkNotNull(v, "groupByColumn must not be null"); return this; } @CanIgnoreReturnValue public Builder setOutputColumn(ResolvedColumn v) { this.outputColumn = v; Preconditions.checkNotNull(v, "outputColumn must not be null"); return this; } @Override public final ResolvedGroupingCall build() { validate(); return new ResolvedGroupingCall( groupByColumn, outputColumn); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( groupByColumn != null, "groupByColumn must be set"); Preconditions.checkArgument( outputColumn != null, "outputColumn must be set"); } } public static final ResolvedGroupingCall deserialize( ResolvedGroupingCallProto proto, AbstractDeserializationHelper helper) { return new ResolvedGroupingCall(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GROUPING_CALL; } @Override public final String nodeKindString() { return "GroupingCall"; } /** * 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(); ResolvedGroupingCallProto.Builder childBuilder = ResolvedGroupingCallProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGroupingCallNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGroupingCallProto.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, ResolvedGroupingCallProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // groupByColumn is an AST node. Call its serialization chain. if (this.getGroupByColumn() != null) { ResolvedColumnRefProto.Builder groupByColumnBuilder = ResolvedColumnRefProto.newBuilder(); this.getGroupByColumn().serialize( fileDescriptorSetsBuilder, groupByColumnBuilder); proto.setGroupByColumn( groupByColumnBuilder.build()); } // outputColumn is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getOutputColumn() != null) { proto.setOutputColumn( ResolvedNodes.serialize(this.getOutputColumn(), fileDescriptorSetsBuilder)); } } public final ResolvedColumnRef getGroupByColumn() { return groupByColumn; } public final ResolvedColumn getOutputColumn() { return outputColumn; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGroupingCall accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(groupByColumn); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (groupByColumn != null) { fields.add(new DebugStringField("group_by_column", groupByColumn)); } { fields.add(new DebugStringField("output_column", DebugStrings.toStringImpl(outputColumn))); } } } /** * The parent node for grouping set, rollup and cube nodes. * *

This node exists for organizational purposes only, to cluster * grouping set, rollup and cube nodes. It doesn't have any actual fields. */ public static abstract class ResolvedGroupingSetBase extends ResolvedArgument { ResolvedGroupingSetBase(ResolvedGroupingSetBaseProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedGroupingSetBase() { super(); } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedArgument.Builder { private Builder() {} @Override public abstract ResolvedGroupingSetBase build(); @Override protected void validate() { super.validate(); } } public static ResolvedGroupingSetBase deserialize( AnyResolvedGroupingSetBaseProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_GROUPING_SET_NODE: return ResolvedGroupingSet.deserialize( proto.getResolvedGroupingSetNode(), helper); case RESOLVED_ROLLUP_NODE: return ResolvedRollup.deserialize( proto.getResolvedRollupNode(), helper); case RESOLVED_CUBE_NODE: return ResolvedCube.deserialize( proto.getResolvedCubeNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedGroupingSetBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedGroupingSetBaseProto.Builder builder = ResolvedGroupingSetBaseProto.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(); AnyResolvedGroupingSetBaseProto.Builder childBuilder = AnyResolvedGroupingSetBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGroupingSetBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedGroupingSetBaseProto.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, AnyResolvedGroupingSetBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedGroupingSetBaseProto.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, ResolvedGroupingSetBaseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public abstract ResolvedGroupingSetBase accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * 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 ResolvedGroupingSetBase { private final ImmutableList groupByColumnList; ResolvedGroupingSet(ResolvedGroupingSetProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder groupByColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getGroupByColumnListList()) { groupByColumnListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } groupByColumnList = groupByColumnListBuilder.build(); } ResolvedGroupingSet( ImmutableList groupByColumnList) { super(); this.groupByColumnList = groupByColumnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.groupByColumnList = this.getGroupByColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGroupingSetBase.Builder { protected ImmutableList groupByColumnList = null; private Builder() {} @CanIgnoreReturnValue public Builder setGroupByColumnList(List v) { this.groupByColumnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGroupingSet build() { validate(); return new ResolvedGroupingSet( groupByColumnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( groupByColumnList != null, "groupByColumnList must be set"); } } public static final ResolvedGroupingSet deserialize( ResolvedGroupingSetProto proto, AbstractDeserializationHelper 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 AnyResolvedGroupingSetBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGroupingSetBaseProto.Builder builder = AnyResolvedGroupingSetBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGroupingSetBaseProto.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, AnyResolvedGroupingSetBaseProto.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. ResolvedGroupingSetBaseProto parent = (ResolvedGroupingSetBaseProto) 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 public ResolvedGroupingSet accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(groupByColumnList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!groupByColumnList.isEmpty()) { fields.add(new DebugStringField("group_by_column_list", groupByColumnList)); } } } /** * List of ResolvedGroupingSetMultiColumn that forms a rollup. * *

Each ResolvedGroupingSetMultiColumn is a list of column references that * will be batched together when expanding to grouping sets. E.g. * ROLLUP((a, b), c) is expanded to grouping sets [(a, b, c), (a, b), ()]. * Both (a, b) and c are store in ResolvedGroupingSetMultiColumn for * convenience. * *

Column references in each ResolvedGroupingSetMultiColumn must come from * group_by_list in ResolvedAggregateScan. It is allowed to have * duplicated ResolvedGroupingSetMultiColumn in rollup_column_list. */ public static final class ResolvedRollup extends ResolvedGroupingSetBase { private final ImmutableList rollupColumnList; ResolvedRollup(ResolvedRollupProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder rollupColumnListBuilder = ImmutableList.builder(); for (ResolvedGroupingSetMultiColumnProto element : proto.getRollupColumnListList()) { rollupColumnListBuilder .add(ResolvedGroupingSetMultiColumn.deserialize(element, helper)); } rollupColumnList = rollupColumnListBuilder.build(); } ResolvedRollup( ImmutableList rollupColumnList) { super(); this.rollupColumnList = rollupColumnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.rollupColumnList = this.getRollupColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGroupingSetBase.Builder { protected ImmutableList rollupColumnList = null; private Builder() {} @CanIgnoreReturnValue public Builder setRollupColumnList(List v) { this.rollupColumnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedRollup build() { validate(); return new ResolvedRollup( rollupColumnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( rollupColumnList != null, "rollupColumnList must be set"); } } public static final ResolvedRollup deserialize( ResolvedRollupProto proto, AbstractDeserializationHelper helper) { return new ResolvedRollup(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ROLLUP; } @Override public final String nodeKindString() { return "Rollup"; } /** * Serializes this node into a {@link AnyResolvedGroupingSetBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGroupingSetBaseProto.Builder builder = AnyResolvedGroupingSetBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGroupingSetBaseProto.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, AnyResolvedGroupingSetBaseProto.Builder builder) { builder.clear(); ResolvedRollupProto.Builder childBuilder = ResolvedRollupProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRollupNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRollupProto.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, ResolvedRollupProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGroupingSetBaseProto parent = (ResolvedGroupingSetBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // rollupColumnList is a collection of AST nodes. Serialize each of them. ImmutableList rollupColumnLists = this.getRollupColumnList(); for (ResolvedGroupingSetMultiColumn element : rollupColumnLists) { ResolvedGroupingSetMultiColumnProto.Builder rollupColumnListBuilder = ResolvedGroupingSetMultiColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, rollupColumnListBuilder); proto.addRollupColumnList(rollupColumnListBuilder.build()); } } public final ImmutableList getRollupColumnList() { return rollupColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedRollup accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(rollupColumnList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!rollupColumnList.isEmpty()) { fields.add(new DebugStringField("rollup_column_list", rollupColumnList)); } } } /** * List of ResolvedGroupingSetMultiColumn that forms a cube in grouping sets. * *

See comments in ResolvdRollup for explanation about * ResolvedGroupingSetMultiColumn. */ public static final class ResolvedCube extends ResolvedGroupingSetBase { private final ImmutableList cubeColumnList; ResolvedCube(ResolvedCubeProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder cubeColumnListBuilder = ImmutableList.builder(); for (ResolvedGroupingSetMultiColumnProto element : proto.getCubeColumnListList()) { cubeColumnListBuilder .add(ResolvedGroupingSetMultiColumn.deserialize(element, helper)); } cubeColumnList = cubeColumnListBuilder.build(); } ResolvedCube( ImmutableList cubeColumnList) { super(); this.cubeColumnList = cubeColumnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.cubeColumnList = this.getCubeColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGroupingSetBase.Builder { protected ImmutableList cubeColumnList = null; private Builder() {} @CanIgnoreReturnValue public Builder setCubeColumnList(List v) { this.cubeColumnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCube build() { validate(); return new ResolvedCube( cubeColumnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( cubeColumnList != null, "cubeColumnList must be set"); } } public static final ResolvedCube deserialize( ResolvedCubeProto proto, AbstractDeserializationHelper helper) { return new ResolvedCube(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CUBE; } @Override public final String nodeKindString() { return "Cube"; } /** * Serializes this node into a {@link AnyResolvedGroupingSetBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGroupingSetBaseProto.Builder builder = AnyResolvedGroupingSetBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGroupingSetBaseProto.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, AnyResolvedGroupingSetBaseProto.Builder builder) { builder.clear(); ResolvedCubeProto.Builder childBuilder = ResolvedCubeProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCubeNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCubeProto.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, ResolvedCubeProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGroupingSetBaseProto parent = (ResolvedGroupingSetBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // cubeColumnList is a collection of AST nodes. Serialize each of them. ImmutableList cubeColumnLists = this.getCubeColumnList(); for (ResolvedGroupingSetMultiColumn element : cubeColumnLists) { ResolvedGroupingSetMultiColumnProto.Builder cubeColumnListBuilder = ResolvedGroupingSetMultiColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, cubeColumnListBuilder); proto.addCubeColumnList(cubeColumnListBuilder.build()); } } public final ImmutableList getCubeColumnList() { return cubeColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCube accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(cubeColumnList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!cubeColumnList.isEmpty()) { fields.add(new DebugStringField("cube_column_list", cubeColumnList)); } } } /** * 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. * *

is either empty to indicate that all the elements in * have the default collation, or has the * same number of elements as . Each element is the collation * for the element in with the same index, or can be empty to * indicate default collation or when the type is not collatable. * is only set when FEATURE_V_1_3_COLLATION_SUPPORT is * enabled. * See (broken link). * *

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. * *

If is empty, output rows grouped by the full * . * *

If is non-empty, then * for each item in , output rows computing the * same over the input rows using a particular grouping set. * Each item in is either a ResolvedGroupingSet, * ResolvedRollup, or ResolvedCube before the grouping set rewriter expands * the grouping set list. After rewriting, it will only contain * ResolvedGroupingSet that are expanded from grouping set, rollup and cube. * *

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 . * *

is the list of resolved group-by columns referenced * in GROUPING aggregate function calls. Each item in the grouping_call_list * is associated with a unique GROUPING function call in the SELECT list. */ public static abstract class ResolvedAggregateScanBase extends ResolvedScan { private final ResolvedScan inputScan; private final ImmutableList groupByList; private final ImmutableList collationList; private final ImmutableList aggregateList; private final ImmutableList groupingSetList; private final ImmutableList rollupColumnList; private final ImmutableList groupingCallList; ResolvedAggregateScanBase(ResolvedAggregateScanBaseProto proto, AbstractDeserializationHelper 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 collationListBuilder = ImmutableList.builder(); for (ResolvedCollationProto element : proto.getCollationListList()) { collationListBuilder.add(helper.deserialize(element)); } collationList = collationListBuilder.build(); ImmutableList.Builder aggregateListBuilder = ImmutableList.builder(); for (AnyResolvedComputedColumnBaseProto element : proto.getAggregateListList()) { aggregateListBuilder .add(ResolvedComputedColumnBase.deserialize(element, helper)); } aggregateList = aggregateListBuilder.build(); ImmutableList.Builder groupingSetListBuilder = ImmutableList.builder(); for (AnyResolvedGroupingSetBaseProto element : proto.getGroupingSetListList()) { groupingSetListBuilder .add(ResolvedGroupingSetBase.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(); ImmutableList.Builder groupingCallListBuilder = ImmutableList.builder(); for (ResolvedGroupingCallProto element : proto.getGroupingCallListList()) { groupingCallListBuilder .add(ResolvedGroupingCall.deserialize(element, helper)); } groupingCallList = groupingCallListBuilder.build(); } ResolvedAggregateScanBase( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList groupByList, ImmutableList collationList, ImmutableList aggregateList, ImmutableList groupingSetList, ImmutableList rollupColumnList, ImmutableList groupingCallList) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.groupByList = groupByList; this.collationList = collationList; this.aggregateList = aggregateList; this.groupingSetList = groupingSetList; this.rollupColumnList = rollupColumnList; this.groupingCallList = groupingCallList; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ImmutableList groupByList = null; protected ImmutableList collationList = ImmutableList.of(); protected ImmutableList aggregateList = null; protected ImmutableList groupingSetList = null; protected ImmutableList rollupColumnList = null; protected ImmutableList groupingCallList = ImmutableList.of(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setGroupByList(List v) { this.groupByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setCollationList(List v) { this.collationList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setAggregateList(List v) { this.aggregateList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setGroupingSetList(List v) { this.groupingSetList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setRollupColumnList(List v) { this.rollupColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setGroupingCallList(List v) { this.groupingCallList = ImmutableList.copyOf(v); return this; } @Override public abstract ResolvedAggregateScanBase build(); @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( groupByList != null, "groupByList must be set"); Preconditions.checkArgument( aggregateList != null, "aggregateList must be set"); } } public static ResolvedAggregateScanBase deserialize( AnyResolvedAggregateScanBaseProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_AGGREGATE_SCAN_NODE: return ResolvedAggregateScan.deserialize( proto.getResolvedAggregateScanNode(), helper); case RESOLVED_ANONYMIZED_AGGREGATE_SCAN_NODE: return ResolvedAnonymizedAggregateScan.deserialize( proto.getResolvedAnonymizedAggregateScanNode(), helper); case RESOLVED_DIFFERENTIAL_PRIVACY_AGGREGATE_SCAN_NODE: return ResolvedDifferentialPrivacyAggregateScan.deserialize( proto.getResolvedDifferentialPrivacyAggregateScanNode(), helper); case RESOLVED_AGGREGATION_THRESHOLD_AGGREGATE_SCAN_NODE: return ResolvedAggregationThresholdAggregateScan.deserialize( proto.getResolvedAggregationThresholdAggregateScanNode(), 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()); } // collationList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList collationLists = this.getCollationList(); for (ResolvedCollation element : collationLists) { proto.addCollationList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // aggregateList is a collection of AST nodes. Serialize each of them. ImmutableList aggregateLists = this.getAggregateList(); for (ResolvedComputedColumnBase element : aggregateLists) { AnyResolvedComputedColumnBaseProto.Builder aggregateListBuilder = AnyResolvedComputedColumnBaseProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, aggregateListBuilder); proto.addAggregateList(aggregateListBuilder.build()); } // groupingSetList is a collection of AST nodes. Serialize each of them. ImmutableList groupingSetLists = this.getGroupingSetList(); for (ResolvedGroupingSetBase element : groupingSetLists) { AnyResolvedGroupingSetBaseProto.Builder groupingSetListBuilder = AnyResolvedGroupingSetBaseProto.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()); } // groupingCallList is a collection of AST nodes. Serialize each of them. ImmutableList groupingCallLists = this.getGroupingCallList(); for (ResolvedGroupingCall element : groupingCallLists) { ResolvedGroupingCallProto.Builder groupingCallListBuilder = ResolvedGroupingCallProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, groupingCallListBuilder); proto.addGroupingCallList(groupingCallListBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ImmutableList getGroupByList() { return groupByList; } public final ImmutableList getCollationList() { return collationList; } public final ImmutableList getAggregateList() { return aggregateList; } public final ImmutableList getGroupingSetList() { return groupingSetList; } public final ImmutableList getRollupColumnList() { return rollupColumnList; } public final ImmutableList getGroupingCallList() { return groupingCallList; } @Override public abstract ResolvedAggregateScanBase accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(groupByList); visitor.descend(aggregateList); visitor.descend(groupingSetList); visitor.descend(rollupColumnList); visitor.descend(groupingCallList); } public 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 (!DebugStrings.isDefaultValue(collationList)) { fields.add(new DebugStringField("collation_list", DebugStrings.toStringCommaSeparated(collationList))); } if (!aggregateList.isEmpty()) { fields.add(new DebugStringField("aggregate_list", aggregateList)); } if (!groupingSetList.isEmpty()) { fields.add(new DebugStringField("grouping_set_list", groupingSetList)); } if (!rollupColumnList.isEmpty()) { fields.add(new DebugStringField("rollup_column_list", rollupColumnList)); } if (!groupingCallList.isEmpty()) { fields.add(new DebugStringField("grouping_call_list", groupingCallList)); } } } /** * Apply aggregation to rows produced from input_scan, and output aggregated * rows. */ public static final class ResolvedAggregateScan extends ResolvedAggregateScanBase { ResolvedAggregateScan(ResolvedAggregateScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAggregateScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList groupByList, ImmutableList collationList, ImmutableList aggregateList, ImmutableList groupingSetList, ImmutableList rollupColumnList, ImmutableList groupingCallList) { super( columnList, hintList, isOrdered, nodeSource, inputScan, groupByList, collationList, aggregateList, groupingSetList, rollupColumnList, groupingCallList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.groupByList = this.getGroupByList(); builder.collationList = this.getCollationList(); builder.aggregateList = this.getAggregateList(); builder.groupingSetList = this.getGroupingSetList(); builder.rollupColumnList = this.getRollupColumnList(); builder.groupingCallList = this.getGroupingCallList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAggregateScanBase.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { super.setInputScan(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupByList(List v) { super.setGroupByList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationList(List v) { super.setCollationList(v); return this; } @Override @CanIgnoreReturnValue public Builder setAggregateList(List v) { super.setAggregateList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupingSetList(List v) { super.setGroupingSetList(v); return this; } @Override @CanIgnoreReturnValue public Builder setRollupColumnList(List v) { super.setRollupColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupingCallList(List v) { super.setGroupingCallList(v); return this; } @Override public final ResolvedAggregateScan build() { validate(); return new ResolvedAggregateScan( columnList, hintList, isOrdered, nodeSource, inputScan, groupByList, collationList, aggregateList, groupingSetList, rollupColumnList, groupingCallList); } @Override protected void validate() { super.validate(); } } public static final ResolvedAggregateScan deserialize( ResolvedAggregateScanProto proto, AbstractDeserializationHelper 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); } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAggregateScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * Apply differentially private aggregation (anonymization) to rows produced * from input_scan, and output anonymized rows. * Spec: (broken link) * *

when non-null, is a function call that uses one or more * items from the as arguments. * The engine then adds a filter that acts like: * HAVING >= * omitting any rows that would not pass this condition. * TODO: Update this comment after splitting the rewriter out * into a separate stage. * *

provides user-specified options, and * requires that option names are one of: delta, epsilon, kappa, * max_groups_contributed, max_rows_contributed, or k_threshold. */ public static final class ResolvedAnonymizedAggregateScan extends ResolvedAggregateScanBase { private final ResolvedExpr kThresholdExpr; private final ImmutableList anonymizationOptionList; ResolvedAnonymizedAggregateScan(ResolvedAnonymizedAggregateScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasKThresholdExpr()) { kThresholdExpr = ResolvedExpr.deserialize(proto.getKThresholdExpr(), helper); } else { kThresholdExpr = null; } ImmutableList.Builder anonymizationOptionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getAnonymizationOptionListList()) { anonymizationOptionListBuilder .add(ResolvedOption.deserialize(element, helper)); } anonymizationOptionList = anonymizationOptionListBuilder.build(); } ResolvedAnonymizedAggregateScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList groupByList, ImmutableList collationList, ImmutableList aggregateList, ImmutableList groupingSetList, ImmutableList rollupColumnList, ImmutableList groupingCallList, ResolvedExpr kThresholdExpr, ImmutableList anonymizationOptionList) { super( columnList, hintList, isOrdered, nodeSource, inputScan, groupByList, collationList, aggregateList, groupingSetList, rollupColumnList, groupingCallList); this.kThresholdExpr = kThresholdExpr; this.anonymizationOptionList = anonymizationOptionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.groupByList = this.getGroupByList(); builder.collationList = this.getCollationList(); builder.aggregateList = this.getAggregateList(); builder.groupingSetList = this.getGroupingSetList(); builder.rollupColumnList = this.getRollupColumnList(); builder.groupingCallList = this.getGroupingCallList(); builder.kThresholdExpr = this.getKThresholdExpr(); builder.anonymizationOptionList = this.getAnonymizationOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAggregateScanBase.Builder { protected ResolvedExpr kThresholdExpr = null; protected ImmutableList anonymizationOptionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { super.setInputScan(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupByList(List v) { super.setGroupByList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationList(List v) { super.setCollationList(v); return this; } @Override @CanIgnoreReturnValue public Builder setAggregateList(List v) { super.setAggregateList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupingSetList(List v) { super.setGroupingSetList(v); return this; } @Override @CanIgnoreReturnValue public Builder setRollupColumnList(List v) { super.setRollupColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupingCallList(List v) { super.setGroupingCallList(v); return this; } @CanIgnoreReturnValue public Builder setKThresholdExpr(ResolvedExpr v) { this.kThresholdExpr = v; Preconditions.checkNotNull(v, "kThresholdExpr must not be null"); return this; } @CanIgnoreReturnValue public Builder setAnonymizationOptionList(List v) { this.anonymizationOptionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedAnonymizedAggregateScan build() { validate(); return new ResolvedAnonymizedAggregateScan( columnList, hintList, isOrdered, nodeSource, inputScan, groupByList, collationList, aggregateList, groupingSetList, rollupColumnList, groupingCallList, kThresholdExpr, anonymizationOptionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( kThresholdExpr != null, "kThresholdExpr must be set"); } } public static final ResolvedAnonymizedAggregateScan deserialize( ResolvedAnonymizedAggregateScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedAnonymizedAggregateScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ANONYMIZED_AGGREGATE_SCAN; } @Override public final String nodeKindString() { return "AnonymizedAggregateScan"; } /** * 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(); ResolvedAnonymizedAggregateScanProto.Builder childBuilder = ResolvedAnonymizedAggregateScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAnonymizedAggregateScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAnonymizedAggregateScanProto.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, ResolvedAnonymizedAggregateScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAggregateScanBaseProto parent = (ResolvedAggregateScanBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // kThresholdExpr is an AST node. Call its serialization chain. if (this.getKThresholdExpr() != null) { AnyResolvedExprProto.Builder kThresholdExprBuilder = AnyResolvedExprProto.newBuilder(); this.getKThresholdExpr().serialize( fileDescriptorSetsBuilder, kThresholdExprBuilder); proto.setKThresholdExpr( kThresholdExprBuilder.build()); } // anonymizationOptionList is a collection of AST nodes. Serialize each of them. ImmutableList anonymizationOptionLists = this.getAnonymizationOptionList(); for (ResolvedOption element : anonymizationOptionLists) { ResolvedOptionProto.Builder anonymizationOptionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, anonymizationOptionListBuilder); proto.addAnonymizationOptionList(anonymizationOptionListBuilder.build()); } } public final ResolvedExpr getKThresholdExpr() { return kThresholdExpr; } public final ImmutableList getAnonymizationOptionList() { return anonymizationOptionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAnonymizedAggregateScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(kThresholdExpr); visitor.descend(anonymizationOptionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (kThresholdExpr != null) { fields.add(new DebugStringField("k_threshold_expr", kThresholdExpr)); } if (!anonymizationOptionList.isEmpty()) { fields.add(new DebugStringField("anonymization_option_list", anonymizationOptionList)); } } } /** * Apply differentially private aggregation (anonymization) to rows produced * from input_scan, and output anonymized rows. * Spec: (broken link) * * *

when non-null, is a function call that * uses one or more items from the as arguments. * The engine then adds a filter that acts like: * HAVING >= * * omitting any rows that would not pass this condition. * TODO: Update this comment after splitting the rewriter out * into a separate stage. * *

provides user-specified options, and * requires that option names are one of: delta, epsilon, * max_groups_contributed or max_rows_contributed. */ public static final class ResolvedDifferentialPrivacyAggregateScan extends ResolvedAggregateScanBase { private final ResolvedExpr groupSelectionThresholdExpr; private final ImmutableList optionList; ResolvedDifferentialPrivacyAggregateScan(ResolvedDifferentialPrivacyAggregateScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasGroupSelectionThresholdExpr()) { groupSelectionThresholdExpr = ResolvedExpr.deserialize(proto.getGroupSelectionThresholdExpr(), helper); } else { groupSelectionThresholdExpr = null; } ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedDifferentialPrivacyAggregateScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList groupByList, ImmutableList collationList, ImmutableList aggregateList, ImmutableList groupingSetList, ImmutableList rollupColumnList, ImmutableList groupingCallList, ResolvedExpr groupSelectionThresholdExpr, ImmutableList optionList) { super( columnList, hintList, isOrdered, nodeSource, inputScan, groupByList, collationList, aggregateList, groupingSetList, rollupColumnList, groupingCallList); this.groupSelectionThresholdExpr = groupSelectionThresholdExpr; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.groupByList = this.getGroupByList(); builder.collationList = this.getCollationList(); builder.aggregateList = this.getAggregateList(); builder.groupingSetList = this.getGroupingSetList(); builder.rollupColumnList = this.getRollupColumnList(); builder.groupingCallList = this.getGroupingCallList(); builder.groupSelectionThresholdExpr = this.getGroupSelectionThresholdExpr(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAggregateScanBase.Builder { protected ResolvedExpr groupSelectionThresholdExpr = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { super.setInputScan(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupByList(List v) { super.setGroupByList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationList(List v) { super.setCollationList(v); return this; } @Override @CanIgnoreReturnValue public Builder setAggregateList(List v) { super.setAggregateList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupingSetList(List v) { super.setGroupingSetList(v); return this; } @Override @CanIgnoreReturnValue public Builder setRollupColumnList(List v) { super.setRollupColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupingCallList(List v) { super.setGroupingCallList(v); return this; } @CanIgnoreReturnValue public Builder setGroupSelectionThresholdExpr(ResolvedExpr v) { this.groupSelectionThresholdExpr = v; Preconditions.checkNotNull(v, "groupSelectionThresholdExpr must not be null"); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedDifferentialPrivacyAggregateScan build() { validate(); return new ResolvedDifferentialPrivacyAggregateScan( columnList, hintList, isOrdered, nodeSource, inputScan, groupByList, collationList, aggregateList, groupingSetList, rollupColumnList, groupingCallList, groupSelectionThresholdExpr, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( groupSelectionThresholdExpr != null, "groupSelectionThresholdExpr must be set"); } } public static final ResolvedDifferentialPrivacyAggregateScan deserialize( ResolvedDifferentialPrivacyAggregateScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedDifferentialPrivacyAggregateScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DIFFERENTIAL_PRIVACY_AGGREGATE_SCAN; } @Override public final String nodeKindString() { return "DifferentialPrivacyAggregateScan"; } /** * 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(); ResolvedDifferentialPrivacyAggregateScanProto.Builder childBuilder = ResolvedDifferentialPrivacyAggregateScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDifferentialPrivacyAggregateScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDifferentialPrivacyAggregateScanProto.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, ResolvedDifferentialPrivacyAggregateScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAggregateScanBaseProto parent = (ResolvedAggregateScanBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // groupSelectionThresholdExpr is an AST node. Call its serialization chain. if (this.getGroupSelectionThresholdExpr() != null) { AnyResolvedExprProto.Builder groupSelectionThresholdExprBuilder = AnyResolvedExprProto.newBuilder(); this.getGroupSelectionThresholdExpr().serialize( fileDescriptorSetsBuilder, groupSelectionThresholdExprBuilder); proto.setGroupSelectionThresholdExpr( groupSelectionThresholdExprBuilder.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()); } } public final ResolvedExpr getGroupSelectionThresholdExpr() { return groupSelectionThresholdExpr; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDifferentialPrivacyAggregateScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(groupSelectionThresholdExpr); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (groupSelectionThresholdExpr != null) { fields.add(new DebugStringField("group_selection_threshold_expr", groupSelectionThresholdExpr)); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * Apply aggregation to rows produced from input_scan and output rows to * that pass aggregation thresholds. It adds: * HAVING COUNT(DISTINCT `privacy_unit_column`) >= `threshold`. * Spec: (broken link) * *

provides user-specified options. Allowed options are defined * in GetAllowedAggregationThresholdOptions function. */ public static final class ResolvedAggregationThresholdAggregateScan extends ResolvedAggregateScanBase { private final ImmutableList optionList; ResolvedAggregationThresholdAggregateScan(ResolvedAggregationThresholdAggregateScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedAggregationThresholdAggregateScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList groupByList, ImmutableList collationList, ImmutableList aggregateList, ImmutableList groupingSetList, ImmutableList rollupColumnList, ImmutableList groupingCallList, ImmutableList optionList) { super( columnList, hintList, isOrdered, nodeSource, inputScan, groupByList, collationList, aggregateList, groupingSetList, rollupColumnList, groupingCallList); this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.groupByList = this.getGroupByList(); builder.collationList = this.getCollationList(); builder.aggregateList = this.getAggregateList(); builder.groupingSetList = this.getGroupingSetList(); builder.rollupColumnList = this.getRollupColumnList(); builder.groupingCallList = this.getGroupingCallList(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAggregateScanBase.Builder { protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { super.setInputScan(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupByList(List v) { super.setGroupByList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationList(List v) { super.setCollationList(v); return this; } @Override @CanIgnoreReturnValue public Builder setAggregateList(List v) { super.setAggregateList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupingSetList(List v) { super.setGroupingSetList(v); return this; } @Override @CanIgnoreReturnValue public Builder setRollupColumnList(List v) { super.setRollupColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGroupingCallList(List v) { super.setGroupingCallList(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedAggregationThresholdAggregateScan build() { validate(); return new ResolvedAggregationThresholdAggregateScan( columnList, hintList, isOrdered, nodeSource, inputScan, groupByList, collationList, aggregateList, groupingSetList, rollupColumnList, groupingCallList, optionList); } @Override protected void validate() { super.validate(); } } public static final ResolvedAggregationThresholdAggregateScan deserialize( ResolvedAggregationThresholdAggregateScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedAggregationThresholdAggregateScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_AGGREGATION_THRESHOLD_AGGREGATE_SCAN; } @Override public final String nodeKindString() { return "AggregationThresholdAggregateScan"; } /** * 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(); ResolvedAggregationThresholdAggregateScanProto.Builder childBuilder = ResolvedAggregationThresholdAggregateScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAggregationThresholdAggregateScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAggregationThresholdAggregateScanProto.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, ResolvedAggregationThresholdAggregateScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAggregateScanBaseProto parent = (ResolvedAggregateScanBaseProto) 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 public ResolvedAggregationThresholdAggregateScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * 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; ResolvedSetOperationItem(ResolvedSetOperationItemProto proto, AbstractDeserializationHelper 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(); } ResolvedSetOperationItem( ResolvedScan scan, ImmutableList outputColumnList) { super(); this.scan = scan; this.outputColumnList = outputColumnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.scan = this.getScan(); builder.outputColumnList = this.getOutputColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedScan scan = null; protected ImmutableList outputColumnList = null; private Builder() {} @CanIgnoreReturnValue public Builder setScan(ResolvedScan v) { this.scan = v; Preconditions.checkNotNull(v, "scan must not be null"); return this; } @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedSetOperationItem build() { validate(); return new ResolvedSetOperationItem( scan, outputColumnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( scan != null, "scan must be set"); Preconditions.checkArgument( outputColumnList != null, "outputColumnList must be set"); } } public static final ResolvedSetOperationItem deserialize( ResolvedSetOperationItemProto proto, AbstractDeserializationHelper 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 public ResolvedSetOperationItem accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(scan); } public 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. * *

represents how columns from different queries were * matched, for example BY_POSITION or CORRESPONDING (by name). Engines can * ignore this field; it is included for informational purposes. * *

represents how non-matching columns were * treated, for example INNER (non-matching columns are dropped) or STRICT * (non-matching columns are not allowed). Engines can ignore this field; * it is included for informational purposes. */ public static final class ResolvedSetOperationScan extends ResolvedScan { private final SetOperationType opType; private final ImmutableList inputItemList; private final SetOperationColumnMatchMode columnMatchMode; private final SetOperationColumnPropagationMode columnPropagationMode; ResolvedSetOperationScan(ResolvedSetOperationScanProto proto, AbstractDeserializationHelper 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(); columnMatchMode = proto.getColumnMatchMode(); columnPropagationMode = proto.getColumnPropagationMode(); } ResolvedSetOperationScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, SetOperationType opType, ImmutableList inputItemList, SetOperationColumnMatchMode columnMatchMode, SetOperationColumnPropagationMode columnPropagationMode) { super( columnList, hintList, isOrdered, nodeSource); this.opType = opType; this.inputItemList = inputItemList; this.columnMatchMode = columnMatchMode; this.columnPropagationMode = columnPropagationMode; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.opType = this.getOpType(); builder.inputItemList = this.getInputItemList(); builder.columnMatchMode = this.getColumnMatchMode(); builder.columnPropagationMode = this.getColumnPropagationMode(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected SetOperationType opType = null; protected ImmutableList inputItemList = null; protected SetOperationColumnMatchMode columnMatchMode = SetOperationColumnMatchMode.BY_POSITION; protected SetOperationColumnPropagationMode columnPropagationMode = SetOperationColumnPropagationMode.STRICT; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setOpType(SetOperationType v) { this.opType = v; Preconditions.checkNotNull(v, "opType must not be null"); return this; } @CanIgnoreReturnValue public Builder setInputItemList(List v) { this.inputItemList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setColumnMatchMode(SetOperationColumnMatchMode v) { this.columnMatchMode = v; return this; } @CanIgnoreReturnValue public Builder setColumnPropagationMode(SetOperationColumnPropagationMode v) { this.columnPropagationMode = v; return this; } @Override public final ResolvedSetOperationScan build() { validate(); return new ResolvedSetOperationScan( columnList, hintList, isOrdered, nodeSource, opType, inputItemList, columnMatchMode, columnPropagationMode); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( opType != null, "opType must be set"); Preconditions.checkArgument( inputItemList != null, "inputItemList must be set"); } } public static final ResolvedSetOperationScan deserialize( ResolvedSetOperationScanProto proto, AbstractDeserializationHelper 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()); } // columnMatchMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setColumnMatchMode(this.getColumnMatchMode()); // columnPropagationMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setColumnPropagationMode(this.getColumnPropagationMode()); } public final SetOperationType getOpType() { return opType; } public final ImmutableList getInputItemList() { return inputItemList; } public final SetOperationColumnMatchMode getColumnMatchMode() { return columnMatchMode; } public final SetOperationColumnPropagationMode getColumnPropagationMode() { return columnPropagationMode; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedSetOperationScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputItemList); } public 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)); } if (!DebugStrings.isDefaultValue(columnMatchMode)) { fields.add(new DebugStringField("column_match_mode", DebugStrings.toStringImpl(columnMatchMode))); } if (!DebugStrings.isDefaultValue(columnPropagationMode)) { fields.add(new DebugStringField("column_propagation_mode", DebugStrings.toStringImpl(columnPropagationMode))); } } } /** * 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; ResolvedOrderByScan(ResolvedOrderByScanProto proto, AbstractDeserializationHelper 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(); } ResolvedOrderByScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList orderByItemList) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.orderByItemList = orderByItemList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.orderByItemList = this.getOrderByItemList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ImmutableList orderByItemList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setOrderByItemList(List v) { this.orderByItemList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedOrderByScan build() { validate(); return new ResolvedOrderByScan( columnList, hintList, isOrdered, nodeSource, inputScan, orderByItemList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( orderByItemList != null, "orderByItemList must be set"); } } public static final ResolvedOrderByScan deserialize( ResolvedOrderByScanProto proto, AbstractDeserializationHelper 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 public ResolvedOrderByScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(orderByItemList); } public 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; ResolvedLimitOffsetScan(ResolvedLimitOffsetScanProto proto, AbstractDeserializationHelper 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; } } ResolvedLimitOffsetScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ResolvedExpr limit, ResolvedExpr offset) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.limit = limit; this.offset = offset; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.limit = this.getLimit(); builder.offset = this.getOffset(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ResolvedExpr limit = null; protected ResolvedExpr offset = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } /** * Note: this method propagates the 'isOrdered' field from {@param v}. * To override this, call setIsOrdered explicitly after calling this * method. */ @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); setIsOrdered(v.getIsOrdered()); return this; } @CanIgnoreReturnValue public Builder setLimit(ResolvedExpr v) { this.limit = v; Preconditions.checkNotNull(v, "limit must not be null"); return this; } @CanIgnoreReturnValue public Builder setOffset(ResolvedExpr v) { this.offset = v; Preconditions.checkNotNull(v, "offset must not be null"); return this; } @Override public final ResolvedLimitOffsetScan build() { validate(); return new ResolvedLimitOffsetScan( columnList, hintList, isOrdered, nodeSource, inputScan, limit, offset); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( limit != null, "limit must be set"); Preconditions.checkArgument( offset != null, "offset must be set"); } } public static final ResolvedLimitOffsetScan deserialize( ResolvedLimitOffsetScanProto proto, AbstractDeserializationHelper 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 public ResolvedLimitOffsetScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(limit); visitor.descend(offset); } public 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 id to each column * produced for this scan. */ public static final class ResolvedWithRefScan extends ResolvedScan { private final String withQueryName; ResolvedWithRefScan(ResolvedWithRefScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); withQueryName = proto.getWithQueryName(); } ResolvedWithRefScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, String withQueryName) { super( columnList, hintList, isOrdered, nodeSource); this.withQueryName = withQueryName; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.withQueryName = this.getWithQueryName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected String withQueryName = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setWithQueryName(String v) { this.withQueryName = v; Preconditions.checkNotNull(v, "withQueryName must not be null"); return this; } @Override public final ResolvedWithRefScan build() { validate(); return new ResolvedWithRefScan( columnList, hintList, isOrdered, nodeSource, withQueryName); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( withQueryName != null, "withQueryName must be set"); } } public static final ResolvedWithRefScan deserialize( ResolvedWithRefScanProto proto, AbstractDeserializationHelper 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 public ResolvedWithRefScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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 contain partitioning/ordering * expression columns if they reference to select columns. * *

Currently, the analyzer combines equivalent OVER clauses into the same * ResolvedAnalyticFunctionGroup only for OVER () or a named window. */ public static final class ResolvedAnalyticScan extends ResolvedScan { private final ResolvedScan inputScan; private final ImmutableList functionGroupList; ResolvedAnalyticScan(ResolvedAnalyticScanProto proto, AbstractDeserializationHelper 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(); } ResolvedAnalyticScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList functionGroupList) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.functionGroupList = functionGroupList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.functionGroupList = this.getFunctionGroupList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ImmutableList functionGroupList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setFunctionGroupList(List v) { this.functionGroupList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedAnalyticScan build() { validate(); return new ResolvedAnalyticScan( columnList, hintList, isOrdered, nodeSource, inputScan, functionGroupList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( functionGroupList != null, "functionGroupList must be set"); } } public static final ResolvedAnalyticScan deserialize( ResolvedAnalyticScanProto proto, AbstractDeserializationHelper 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 public ResolvedAnalyticScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(functionGroupList); } public 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; ResolvedSampleScan(ResolvedSampleScanProto proto, AbstractDeserializationHelper 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(); } ResolvedSampleScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, String method, ResolvedExpr size, SampleUnit unit, ResolvedExpr repeatableArgument, ResolvedColumnHolder weightColumn, ImmutableList partitionByList) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.method = method; this.size = size; this.unit = unit; this.repeatableArgument = repeatableArgument; this.weightColumn = weightColumn; this.partitionByList = partitionByList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.method = this.getMethod(); builder.size = this.getSize(); builder.unit = this.getUnit(); builder.repeatableArgument = this.getRepeatableArgument(); builder.weightColumn = this.getWeightColumn(); builder.partitionByList = this.getPartitionByList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected String method = null; protected ResolvedExpr size = null; protected SampleUnit unit = null; protected ResolvedExpr repeatableArgument = null; protected ResolvedColumnHolder weightColumn = null; protected ImmutableList partitionByList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setMethod(String v) { this.method = v; Preconditions.checkNotNull(v, "method must not be null"); return this; } @CanIgnoreReturnValue public Builder setSize(ResolvedExpr v) { this.size = v; Preconditions.checkNotNull(v, "size must not be null"); return this; } @CanIgnoreReturnValue public Builder setUnit(SampleUnit v) { this.unit = v; Preconditions.checkNotNull(v, "unit must not be null"); return this; } @CanIgnoreReturnValue public Builder setRepeatableArgument(ResolvedExpr v) { this.repeatableArgument = v; Preconditions.checkNotNull(v, "repeatableArgument must not be null"); return this; } @CanIgnoreReturnValue public Builder setWeightColumn(ResolvedColumnHolder v) { this.weightColumn = v; return this; } @CanIgnoreReturnValue public Builder setPartitionByList(List v) { this.partitionByList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedSampleScan build() { validate(); return new ResolvedSampleScan( columnList, hintList, isOrdered, nodeSource, inputScan, method, size, unit, repeatableArgument, weightColumn, partitionByList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( method != null, "method must be set"); Preconditions.checkArgument( size != null, "size must be set"); Preconditions.checkArgument( unit != null, "unit must be set"); Preconditions.checkArgument( repeatableArgument != null, "repeatableArgument must be set"); } } public static final ResolvedSampleScan deserialize( ResolvedSampleScanProto proto, AbstractDeserializationHelper 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 public ResolvedSampleScan accept(RewritingVisitor visitor) { return 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); } public 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. * *

There are 2 concrete subclasses: ResolvedComputedColumn and * ResolvedDeferredComputedColumn. * *

ResolvedDeferredComputedColumn has extra information about deferring * side effects like errors. This can be used in cases like AggregateScans * before conditional expressions like IF(), where errors from the aggregate * function should only be exposed if the right IF branch is chosen. * *

Nodes where deferred side effects are not possible (like GROUP BY * expressions) are declared as ResolvedComputedColumn directly. * *

Nodes that might need to defer errors, such as AggregateScan's * aggregate_list(), are declared as ResolvedComputedColumnBase. * The runtime type will be either ResolvedComputedColumn or * ResolvedDeferredComputedColumn, depending on whether any side effects need * to be captured. * *

If FEATURE_V_1_4_ENFORCE_CONDITIONAL_EVALUATION is not set, the runtime * type is always just ResolvedComputedColumn. * *

See (broken link) for more details. */ public static abstract class ResolvedComputedColumnBase extends ResolvedArgument { ResolvedComputedColumnBase(ResolvedComputedColumnBaseProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedComputedColumnBase() { super(); } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedArgument.Builder { private Builder() {} @Override public abstract ResolvedComputedColumnBase build(); @Override protected void validate() { super.validate(); } } public static ResolvedComputedColumnBase deserialize( AnyResolvedComputedColumnBaseProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_COMPUTED_COLUMN_IMPL_NODE: return ResolvedComputedColumnImpl.deserialize( proto.getResolvedComputedColumnImplNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedComputedColumnBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedComputedColumnBaseProto.Builder builder = ResolvedComputedColumnBaseProto.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(); AnyResolvedComputedColumnBaseProto.Builder childBuilder = AnyResolvedComputedColumnBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedComputedColumnBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedComputedColumnBaseProto.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, AnyResolvedComputedColumnBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedComputedColumnBaseProto.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, ResolvedComputedColumnBaseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } // Special getter for backward compatibility purposes. public abstract ResolvedColumn getColumn(); // Special getter for backward compatibility purposes. public abstract ResolvedExpr getExpr(); @Override public abstract ResolvedComputedColumnBase accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * An intermediate abstract superclass that holds common getters for * ResolvedComputedColumn and ResolvedDeferredComputedColumn. This class * exists to ensure that callers static_cast to the appropriate subclass, * rather than processing ResolvedComputedColumnBase directly. */ public static abstract class ResolvedComputedColumnImpl extends ResolvedComputedColumnBase { ResolvedComputedColumnImpl(ResolvedComputedColumnImplProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedComputedColumnImpl() { super(); } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedComputedColumnBase.Builder { private Builder() {} @Override public abstract ResolvedComputedColumnImpl build(); @Override protected void validate() { super.validate(); } } public static ResolvedComputedColumnImpl deserialize( AnyResolvedComputedColumnImplProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_COMPUTED_COLUMN_NODE: return ResolvedComputedColumn.deserialize( proto.getResolvedComputedColumnNode(), helper); case RESOLVED_DEFERRED_COMPUTED_COLUMN_NODE: return ResolvedDeferredComputedColumn.deserialize( proto.getResolvedDeferredComputedColumnNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedComputedColumnImplProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedComputedColumnImplProto.Builder builder = ResolvedComputedColumnImplProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedComputedColumnBaseProto.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, AnyResolvedComputedColumnBaseProto.Builder builder) { builder.clear(); AnyResolvedComputedColumnImplProto.Builder childBuilder = AnyResolvedComputedColumnImplProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedComputedColumnImplNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedComputedColumnImplProto.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, AnyResolvedComputedColumnImplProto.Builder builder); /** * Serializes this node into the given {@link ResolvedComputedColumnImplProto.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, ResolvedComputedColumnImplProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedComputedColumnBaseProto parent = (ResolvedComputedColumnBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public abstract ResolvedComputedColumnImpl accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This is the usual ResolvedComputedColumn without deferred side effects. * See comments on ResolvedComputedColumnBase. */ public static final class ResolvedComputedColumn extends ResolvedComputedColumnImpl { private final ResolvedColumn column; private final ResolvedExpr expr; ResolvedComputedColumn(ResolvedComputedColumnProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); column = helper.deserialize(proto.getColumn()); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } } ResolvedComputedColumn( ResolvedColumn column, ResolvedExpr expr) { super(); this.column = column; this.expr = expr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.column = this.getColumn(); builder.expr = this.getExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedComputedColumnImpl.Builder { protected ResolvedColumn column = null; protected ResolvedExpr expr = null; private Builder() {} @CanIgnoreReturnValue public Builder setColumn(ResolvedColumn v) { this.column = v; return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @Override public final ResolvedComputedColumn build() { validate(); return new ResolvedComputedColumn( column, expr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); } } public static final ResolvedComputedColumn deserialize( ResolvedComputedColumnProto proto, AbstractDeserializationHelper 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 AnyResolvedComputedColumnImplProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedComputedColumnImplProto.Builder builder = AnyResolvedComputedColumnImplProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedComputedColumnImplProto.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, AnyResolvedComputedColumnImplProto.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. ResolvedComputedColumnImplProto parent = (ResolvedComputedColumnImplProto) 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()); } } @Override public final ResolvedColumn getColumn() { return column; } @Override public final ResolvedExpr getExpr() { return expr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedComputedColumn accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * This is a ResolvedColumnColumn variant that adds deferred side effect * capture. * *

This is used for computations that get separated into multiple scans, * where side effects like errors in earlier scans need to be deferred * util conditional expressions in later scans are evalauted. * See (broken link) for details. * For example: * SELECT IF(C, SUM(A/B), -1) FROM T * The division A/B could produce an error when B is 0, but errors should not * be exposed when C is false, due to IF's conditional evaluation semantics. * *

`side_effect_column` is a new column (of type BYTES) created at the same * time as `column`, storing side effects like errors from the computation. * This column will store an implementation-specific representation of the * side effect (e.g. util::StatusProto) and will get a NULL value if there * are no captured side effects. * *

Typically, this column will be passed to a call to the internal function * $with_side_effect() later to expose the side effects. The validator checks * that it is consumed downstream. */ public static final class ResolvedDeferredComputedColumn extends ResolvedComputedColumnImpl { private final ResolvedColumn column; private final ResolvedExpr expr; /** * Creates the companion side effects columns for this * computation, of type BYTES. Instead of immediately exposing the * side effect (e.g. an error), the side effect is captured in the * side_effects_column. */ private final ResolvedColumn sideEffectColumn; ResolvedDeferredComputedColumn(ResolvedDeferredComputedColumnProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); column = helper.deserialize(proto.getColumn()); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } sideEffectColumn = helper.deserialize(proto.getSideEffectColumn()); } ResolvedDeferredComputedColumn( ResolvedColumn column, ResolvedExpr expr, ResolvedColumn sideEffectColumn) { super(); this.column = column; this.expr = expr; this.sideEffectColumn = sideEffectColumn; } @Override public Builder toBuilder() { Builder builder = builder(); builder.column = this.getColumn(); builder.expr = this.getExpr(); builder.sideEffectColumn = this.getSideEffectColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedComputedColumnImpl.Builder { protected ResolvedColumn column = null; protected ResolvedExpr expr = null; protected ResolvedColumn sideEffectColumn = null; private Builder() {} @CanIgnoreReturnValue public Builder setColumn(ResolvedColumn v) { this.column = v; return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } /** * Creates the companion side effects columns for this * computation, of type BYTES. Instead of immediately exposing the * side effect (e.g. an error), the side effect is captured in the * side_effects_column. */ @CanIgnoreReturnValue public Builder setSideEffectColumn(ResolvedColumn v) { this.sideEffectColumn = v; Preconditions.checkNotNull(v, "sideEffectColumn must not be null"); return this; } @Override public final ResolvedDeferredComputedColumn build() { validate(); return new ResolvedDeferredComputedColumn( column, expr, sideEffectColumn); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( sideEffectColumn != null, "sideEffectColumn must be set"); } } public static final ResolvedDeferredComputedColumn deserialize( ResolvedDeferredComputedColumnProto proto, AbstractDeserializationHelper helper) { return new ResolvedDeferredComputedColumn(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DEFERRED_COMPUTED_COLUMN; } @Override public final String nodeKindString() { return "DeferredComputedColumn"; } /** * Serializes this node into a {@link AnyResolvedComputedColumnImplProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedComputedColumnImplProto.Builder builder = AnyResolvedComputedColumnImplProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedComputedColumnImplProto.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, AnyResolvedComputedColumnImplProto.Builder builder) { builder.clear(); ResolvedDeferredComputedColumnProto.Builder childBuilder = ResolvedDeferredComputedColumnProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDeferredComputedColumnNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDeferredComputedColumnProto.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, ResolvedDeferredComputedColumnProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedComputedColumnImplProto parent = (ResolvedComputedColumnImplProto) 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()); } // sideEffectColumn is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getSideEffectColumn() != null) { proto.setSideEffectColumn( ResolvedNodes.serialize(this.getSideEffectColumn(), fileDescriptorSetsBuilder)); } } @Override public final ResolvedColumn getColumn() { return column; } @Override public final ResolvedExpr getExpr() { return expr; } /** * Creates the companion side effects columns for this * computation, of type BYTES. Instead of immediately exposing the * side effect (e.g. an error), the side effect is captured in the * side_effects_column. */ public final ResolvedColumn getSideEffectColumn() { return sideEffectColumn; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDeferredComputedColumn accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * This represents one column of an ORDER BY clause, with the requested * ordering direction. * *

is the ORDER BY COLLATE expression, and could be a string * literal or query parameter. can only be set when the * FEATURE_V_1_1_ORDER_BY_COLLATE is enabled. * See (broken link) for COLLATE clause. * (only set when FEATURE_V_1_3_COLLATION_SUPPORT is enabled) is * the derived collation to use. It comes from the and COLLATE * clause. It is unset if COLLATE is present and set to a parameter. * See (broken link) for general Collation Support. * When both features are enabled, if is present and is * - a parameter, then is empty * - a non-parameter, then is set to the same collation * An engine which supports both features could read the fields as: * If is set then use it, otherwise use , which * must be a query parameter if set. * *

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; private final ResolvedCollation collation; ResolvedOrderByItem(ResolvedOrderByItemProto proto, AbstractDeserializationHelper 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(); collation = helper.deserialize(proto.getCollation()); } ResolvedOrderByItem( ResolvedColumnRef columnRef, ResolvedExpr collationName, boolean isDescending, NullOrderMode nullOrder, ResolvedCollation collation) { super(); this.columnRef = columnRef; this.collationName = collationName; this.isDescending = isDescending; this.nullOrder = nullOrder; this.collation = collation; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnRef = this.getColumnRef(); builder.collationName = this.getCollationName(); builder.isDescending = this.getIsDescending(); builder.nullOrder = this.getNullOrder(); builder.collation = this.getCollation(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedColumnRef columnRef = null; protected ResolvedExpr collationName = null; protected Boolean isDescending = null; protected NullOrderMode nullOrder = null; protected ResolvedCollation collation = null; private Builder() {} @CanIgnoreReturnValue public Builder setColumnRef(ResolvedColumnRef v) { this.columnRef = v; Preconditions.checkNotNull(v, "columnRef must not be null"); return this; } @CanIgnoreReturnValue public Builder setCollationName(ResolvedExpr v) { this.collationName = v; return this; } @CanIgnoreReturnValue public Builder setIsDescending(boolean v) { this.isDescending = v; return this; } @CanIgnoreReturnValue public Builder setNullOrder(NullOrderMode v) { this.nullOrder = v; return this; } @CanIgnoreReturnValue public Builder setCollation(ResolvedCollation v) { this.collation = v; return this; } @Override public final ResolvedOrderByItem build() { validate(); return new ResolvedOrderByItem( columnRef, collationName, isDescending, nullOrder, collation); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( columnRef != null, "columnRef must be set"); } } public static final ResolvedOrderByItem deserialize( ResolvedOrderByItemProto proto, AbstractDeserializationHelper 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()); // collation is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getCollation() != null) { proto.setCollation( ResolvedNodes.serialize(this.getCollation(), fileDescriptorSetsBuilder)); } } public final ResolvedColumnRef getColumnRef() { return columnRef; } public final ResolvedExpr getCollationName() { return collationName; } public final boolean getIsDescending() { return isDescending; } public final NullOrderMode getNullOrder() { return nullOrder; } public final ResolvedCollation getCollation() { return collation; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedOrderByItem accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnRef); visitor.descend(collationName); } public 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))); } if (!DebugStrings.isDefaultValue(collation)) { fields.add(new DebugStringField("collation", DebugStrings.toStringImpl(collation))); } } } /** * This is used in CREATE TABLE statements to provide column annotations * such as collation, NOT NULL, type parameters, 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 { /** * can only be a string literal, and is only set * when FEATURE_V_1_3_COLLATION_SUPPORT is enabled. See * (broken link). */ private final ResolvedExpr collationName; private final boolean notNull; private final ImmutableList optionList; private final ImmutableList childList; /** * child_list in is not used in here. * Instead we use child_list of this node (ResolvedColumnAnnotations) * to store type parameters of subfields of STRUCT or ARRAY. Users * can access the full type parameters with child_list by calling * ResolvedColumnDefinition.getFullTypeParameters() function. */ private final TypeParameters typeParameters; ResolvedColumnAnnotations(ResolvedColumnAnnotationsProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasCollationName()) { collationName = ResolvedExpr.deserialize(proto.getCollationName(), helper); } else { collationName = null; } 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(); typeParameters = helper.deserialize(proto.getTypeParameters()); } ResolvedColumnAnnotations( ResolvedExpr collationName, boolean notNull, ImmutableList optionList, ImmutableList childList, TypeParameters typeParameters) { super(); this.collationName = collationName; this.notNull = notNull; this.optionList = optionList; this.childList = childList; this.typeParameters = typeParameters; } @Override public Builder toBuilder() { Builder builder = builder(); builder.collationName = this.getCollationName(); builder.notNull = this.getNotNull(); builder.optionList = this.getOptionList(); builder.childList = this.getChildList(); builder.typeParameters = this.getTypeParameters(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr collationName = null; protected Boolean notNull = null; protected ImmutableList optionList = null; protected ImmutableList childList = null; protected TypeParameters typeParameters = null; private Builder() {} /** * can only be a string literal, and is only set * when FEATURE_V_1_3_COLLATION_SUPPORT is enabled. See * (broken link). */ @CanIgnoreReturnValue public Builder setCollationName(ResolvedExpr v) { this.collationName = v; return this; } @CanIgnoreReturnValue public Builder setNotNull(boolean v) { this.notNull = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setChildList(List v) { this.childList = ImmutableList.copyOf(v); return this; } /** * child_list in is not used in here. * Instead we use child_list of this node (ResolvedColumnAnnotations) * to store type parameters of subfields of STRUCT or ARRAY. Users * can access the full type parameters with child_list by calling * ResolvedColumnDefinition.getFullTypeParameters() function. */ @CanIgnoreReturnValue public Builder setTypeParameters(TypeParameters v) { this.typeParameters = v; return this; } @Override public final ResolvedColumnAnnotations build() { validate(); return new ResolvedColumnAnnotations( collationName, notNull, optionList, childList, typeParameters); } @Override protected void validate() { super.validate(); } } public static final ResolvedColumnAnnotations deserialize( ResolvedColumnAnnotationsProto proto, AbstractDeserializationHelper 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); // 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()); } // 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()); } // typeParameters is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getTypeParameters() != null) { proto.setTypeParameters( ResolvedNodes.serialize(this.getTypeParameters(), fileDescriptorSetsBuilder)); } } /** * can only be a string literal, and is only set * when FEATURE_V_1_3_COLLATION_SUPPORT is enabled. See * (broken link). */ public final ResolvedExpr getCollationName() { return collationName; } public final boolean getNotNull() { return notNull; } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getChildList() { return childList; } /** * child_list in is not used in here. * Instead we use child_list of this node (ResolvedColumnAnnotations) * to store type parameters of subfields of STRUCT or ARRAY. Users * can access the full type parameters with child_list by calling * ResolvedColumnDefinition.getFullTypeParameters() function. */ public final TypeParameters getTypeParameters() { return typeParameters; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedColumnAnnotations accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(collationName); visitor.descend(optionList); visitor.descend(childList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (collationName != null) { fields.add(new DebugStringField("collation_name", collationName)); } 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)); } if (!DebugStrings.isDefaultValue(typeParameters)) { fields.add(new DebugStringField("type_parameters", DebugStrings.toStringImpl(typeParameters))); } } } /** * 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. * *

is the mode of a generated column: Values are: * - 'NON_STORED': The must always be evaluated at read time. * - 'STORED': The should be pre-emptively computed at write * time (to save work at read time) and must not call any volatle * function (e.g. RAND). * - 'STORED_VOLATILE': The must be computed at write time and * may call volatile functions (e.g. RAND). * *

`generated_mode` dictates how the generated column is populated. Values * are: * - 'ALWAYS' the generated value is always applied to the column, * meaning users cannot write to the column. * - 'BY_DEFAULT', the generated value is applied to to the column only if * the user does not write to the column. * This field is set to ALWAYS by default. * *

`identity_column_info` contains the sequence attributes that dictate how * values are generated for the column. * - Each table can have at most one identity column. * *

Note: Exactly one of `expression` and `identity_column_info` must be * populated. * *

See (broken link) and * (broken link). */ public static final class ResolvedGeneratedColumnInfo extends ResolvedArgument { private final ResolvedExpr expression; private final StoredMode storedMode; private final GeneratedMode generatedMode; private final ResolvedIdentityColumnInfo identityColumnInfo; ResolvedGeneratedColumnInfo(ResolvedGeneratedColumnInfoProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpression()) { expression = ResolvedExpr.deserialize(proto.getExpression(), helper); } else { expression = null; } storedMode = proto.getStoredMode(); generatedMode = proto.getGeneratedMode(); if (proto.hasIdentityColumnInfo()) { identityColumnInfo = ResolvedIdentityColumnInfo.deserialize(proto.getIdentityColumnInfo(), helper); } else { identityColumnInfo = null; } } ResolvedGeneratedColumnInfo( ResolvedExpr expression, StoredMode storedMode, GeneratedMode generatedMode, ResolvedIdentityColumnInfo identityColumnInfo) { super(); this.expression = expression; this.storedMode = storedMode; this.generatedMode = generatedMode; this.identityColumnInfo = identityColumnInfo; } @Override public Builder toBuilder() { Builder builder = builder(); builder.expression = this.getExpression(); builder.storedMode = this.getStoredMode(); builder.generatedMode = this.getGeneratedMode(); builder.identityColumnInfo = this.getIdentityColumnInfo(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr expression = null; protected StoredMode storedMode = null; protected GeneratedMode generatedMode = null; protected ResolvedIdentityColumnInfo identityColumnInfo = null; private Builder() {} @CanIgnoreReturnValue public Builder setExpression(ResolvedExpr v) { this.expression = v; return this; } @CanIgnoreReturnValue public Builder setStoredMode(StoredMode v) { this.storedMode = v; return this; } @CanIgnoreReturnValue public Builder setGeneratedMode(GeneratedMode v) { this.generatedMode = v; return this; } @CanIgnoreReturnValue public Builder setIdentityColumnInfo(ResolvedIdentityColumnInfo v) { this.identityColumnInfo = v; return this; } @Override public final ResolvedGeneratedColumnInfo build() { validate(); return new ResolvedGeneratedColumnInfo( expression, storedMode, generatedMode, identityColumnInfo); } @Override protected void validate() { super.validate(); } } public static final ResolvedGeneratedColumnInfo deserialize( ResolvedGeneratedColumnInfoProto proto, AbstractDeserializationHelper 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()); } // storedMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setStoredMode(this.getStoredMode()); // generatedMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setGeneratedMode(this.getGeneratedMode()); // identityColumnInfo is an AST node. Call its serialization chain. if (this.getIdentityColumnInfo() != null) { ResolvedIdentityColumnInfoProto.Builder identityColumnInfoBuilder = ResolvedIdentityColumnInfoProto.newBuilder(); this.getIdentityColumnInfo().serialize( fileDescriptorSetsBuilder, identityColumnInfoBuilder); proto.setIdentityColumnInfo( identityColumnInfoBuilder.build()); } } public final ResolvedExpr getExpression() { return expression; } public final StoredMode getStoredMode() { return storedMode; } public final GeneratedMode getGeneratedMode() { return generatedMode; } public final ResolvedIdentityColumnInfo getIdentityColumnInfo() { return identityColumnInfo; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGeneratedColumnInfo accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); visitor.descend(identityColumnInfo); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expression != null) { fields.add(new DebugStringField("expression", expression)); } if (!DebugStrings.isDefaultValue(storedMode)) { fields.add(new DebugStringField("stored_mode", DebugStrings.toStringImpl(storedMode))); } if (!DebugStrings.isDefaultValue(generatedMode)) { fields.add(new DebugStringField("generated_mode", DebugStrings.toStringImpl(generatedMode))); } if (identityColumnInfo != null) { fields.add(new DebugStringField("identity_column_info", identityColumnInfo)); } } } /** * is the default value expression of the column. The type of * the expression must be coercible to the column type. * - cannot contain any references to another column. * - cannot include a subquery, aggregation, or window * function. * *

is the original SQL string for the default value expression. * *

Since we can't enforce engines to access at least one of the fields, we * leave both fields NOT_IGNORABLE to ensure engines access at least one of * them. */ public static final class ResolvedColumnDefaultValue extends ResolvedArgument { private final ResolvedExpr expression; private final String sql; ResolvedColumnDefaultValue(ResolvedColumnDefaultValueProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpression()) { expression = ResolvedExpr.deserialize(proto.getExpression(), helper); } else { expression = null; } sql = proto.getSql(); } ResolvedColumnDefaultValue( ResolvedExpr expression, String sql) { super(); this.expression = expression; this.sql = sql; } @Override public Builder toBuilder() { Builder builder = builder(); builder.expression = this.getExpression(); builder.sql = this.getSql(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr expression = null; protected String sql = null; private Builder() {} @CanIgnoreReturnValue public Builder setExpression(ResolvedExpr v) { this.expression = v; Preconditions.checkNotNull(v, "expression must not be null"); return this; } @CanIgnoreReturnValue public Builder setSql(String v) { this.sql = v; Preconditions.checkNotNull(v, "sql must not be null"); return this; } @Override public final ResolvedColumnDefaultValue build() { validate(); return new ResolvedColumnDefaultValue( expression, sql); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expression != null, "expression must be set"); Preconditions.checkArgument( sql != null, "sql must be set"); } } public static final ResolvedColumnDefaultValue deserialize( ResolvedColumnDefaultValueProto proto, AbstractDeserializationHelper helper) { return new ResolvedColumnDefaultValue(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_COLUMN_DEFAULT_VALUE; } @Override public final String nodeKindString() { return "ColumnDefaultValue"; } /** * 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(); ResolvedColumnDefaultValueProto.Builder childBuilder = ResolvedColumnDefaultValueProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedColumnDefaultValueNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedColumnDefaultValueProto.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, ResolvedColumnDefaultValueProto.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()); } // 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()); } public final ResolvedExpr getExpression() { return expression; } public final String getSql() { return sql; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedColumnDefaultValue accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expression != null) { fields.add(new DebugStringField("expression", expression)); } { fields.add(new DebugStringField("sql", DebugStrings.toStringImpl(sql))); } } } /** * 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 column is a generated * column. * *

if is non-NULL, then this column has default value. * *

and cannot both be set at the * same time. * *

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; private final ResolvedColumnDefaultValue defaultValue; ResolvedColumnDefinition(ResolvedColumnDefinitionProto proto, AbstractDeserializationHelper 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; } if (proto.hasDefaultValue()) { defaultValue = ResolvedColumnDefaultValue.deserialize(proto.getDefaultValue(), helper); } else { defaultValue = null; } } ResolvedColumnDefinition( String name, Type type, ResolvedColumnAnnotations annotations, boolean isHidden, ResolvedColumn column, ResolvedGeneratedColumnInfo generatedColumnInfo, ResolvedColumnDefaultValue defaultValue) { super(); this.name = name; this.type = type; this.annotations = annotations; this.isHidden = isHidden; this.column = column; this.generatedColumnInfo = generatedColumnInfo; this.defaultValue = defaultValue; } @Override public Builder toBuilder() { Builder builder = builder(); builder.name = this.getName(); builder.type = this.getType(); builder.annotations = this.getAnnotations(); builder.isHidden = this.getIsHidden(); builder.column = this.getColumn(); builder.generatedColumnInfo = this.getGeneratedColumnInfo(); builder.defaultValue = this.getDefaultValue(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String name = null; protected Type type = null; protected ResolvedColumnAnnotations annotations = null; protected Boolean isHidden = null; protected ResolvedColumn column = null; protected ResolvedGeneratedColumnInfo generatedColumnInfo = null; protected ResolvedColumnDefaultValue defaultValue = null; private Builder() {} @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setType(Type v) { this.type = v; Preconditions.checkNotNull(v, "type must not be null"); return this; } @CanIgnoreReturnValue public Builder setAnnotations(ResolvedColumnAnnotations v) { this.annotations = v; return this; } @CanIgnoreReturnValue public Builder setIsHidden(boolean v) { this.isHidden = v; return this; } @CanIgnoreReturnValue public Builder setColumn(ResolvedColumn v) { this.column = v; return this; } @CanIgnoreReturnValue public Builder setGeneratedColumnInfo(ResolvedGeneratedColumnInfo v) { this.generatedColumnInfo = v; return this; } @CanIgnoreReturnValue public Builder setDefaultValue(ResolvedColumnDefaultValue v) { this.defaultValue = v; return this; } @Override public final ResolvedColumnDefinition build() { validate(); return new ResolvedColumnDefinition( name, type, annotations, isHidden, column, generatedColumnInfo, defaultValue); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); Preconditions.checkArgument( type != null, "type must be set"); } } public static final ResolvedColumnDefinition deserialize( ResolvedColumnDefinitionProto proto, AbstractDeserializationHelper 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()); } // defaultValue is an AST node. Call its serialization chain. if (this.getDefaultValue() != null) { ResolvedColumnDefaultValueProto.Builder defaultValueBuilder = ResolvedColumnDefaultValueProto.newBuilder(); this.getDefaultValue().serialize( fileDescriptorSetsBuilder, defaultValueBuilder); proto.setDefaultValue( defaultValueBuilder.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; } public final ResolvedColumnDefaultValue getDefaultValue() { return defaultValue; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedColumnDefinition accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(annotations); visitor.descend(generatedColumnInfo); visitor.descend(defaultValue); } public 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)); } if (defaultValue != null) { fields.add(new DebugStringField("default_value", defaultValue)); } } } /** * Intermediate class for resolved constraints. */ public static abstract class ResolvedConstraint extends ResolvedArgument { ResolvedConstraint(ResolvedConstraintProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedConstraint() { super(); } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedArgument.Builder { private Builder() {} @Override public abstract ResolvedConstraint build(); @Override protected void validate() { super.validate(); } } public static ResolvedConstraint deserialize( AnyResolvedConstraintProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_PRIMARY_KEY_NODE: return ResolvedPrimaryKey.deserialize( proto.getResolvedPrimaryKeyNode(), helper); case RESOLVED_FOREIGN_KEY_NODE: return ResolvedForeignKey.deserialize( proto.getResolvedForeignKeyNode(), helper); case RESOLVED_CHECK_CONSTRAINT_NODE: return ResolvedCheckConstraint.deserialize( proto.getResolvedCheckConstraintNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedConstraintProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedConstraintProto.Builder builder = ResolvedConstraintProto.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(); AnyResolvedConstraintProto.Builder childBuilder = AnyResolvedConstraintProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedConstraintNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedConstraintProto.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, AnyResolvedConstraintProto.Builder builder); /** * Serializes this node into the given {@link ResolvedConstraintProto.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, ResolvedConstraintProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public abstract ResolvedConstraint accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * 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 or when the altered * table does not exist. * specifies whether the constraint is unenforced. * specifies the constraint name, if present * provides the column names used in column definitions * that comprise the primary key. */ public static final class ResolvedPrimaryKey extends ResolvedConstraint { private final ImmutableList columnOffsetList; private final ImmutableList optionList; private final boolean unenforced; private final String constraintName; private final ImmutableList columnNameList; ResolvedPrimaryKey(ResolvedPrimaryKeyProto proto, AbstractDeserializationHelper 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(); unenforced = proto.getUnenforced(); constraintName = proto.getConstraintName(); columnNameList = ImmutableList.copyOf(proto.getColumnNameListList()); } ResolvedPrimaryKey( ImmutableList columnOffsetList, ImmutableList optionList, boolean unenforced, String constraintName, ImmutableList columnNameList) { super(); this.columnOffsetList = columnOffsetList; this.optionList = optionList; this.unenforced = unenforced; this.constraintName = constraintName; this.columnNameList = columnNameList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnOffsetList = this.getColumnOffsetList(); builder.optionList = this.getOptionList(); builder.unenforced = this.getUnenforced(); builder.constraintName = this.getConstraintName(); builder.columnNameList = this.getColumnNameList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedConstraint.Builder { protected ImmutableList columnOffsetList = null; protected ImmutableList optionList = null; protected Boolean unenforced = null; protected String constraintName = null; protected ImmutableList columnNameList = null; private Builder() {} @CanIgnoreReturnValue public Builder setColumnOffsetList(List v) { this.columnOffsetList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setUnenforced(boolean v) { this.unenforced = v; return this; } @CanIgnoreReturnValue public Builder setConstraintName(String v) { this.constraintName = v; return this; } @CanIgnoreReturnValue public Builder setColumnNameList(List v) { this.columnNameList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedPrimaryKey build() { validate(); return new ResolvedPrimaryKey( columnOffsetList, optionList, unenforced, constraintName, columnNameList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( columnOffsetList != null, "columnOffsetList must be set"); } } public static final ResolvedPrimaryKey deserialize( ResolvedPrimaryKeyProto proto, AbstractDeserializationHelper 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 AnyResolvedConstraintProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedConstraintProto.Builder builder = AnyResolvedConstraintProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedConstraintProto.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, AnyResolvedConstraintProto.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. ResolvedConstraintProto parent = (ResolvedConstraintProto) 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()); } // unenforced is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setUnenforced(this.getUnenforced()); // 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()); // columnNameList 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.addAllColumnNameList(this.getColumnNameList()); } public final ImmutableList getColumnOffsetList() { return columnOffsetList; } public final ImmutableList getOptionList() { return optionList; } public final boolean getUnenforced() { return unenforced; } public final String getConstraintName() { return constraintName; } public final ImmutableList getColumnNameList() { return columnNameList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedPrimaryKey accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public 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)); } if (!DebugStrings.isDefaultValue(unenforced)) { fields.add(new DebugStringField("unenforced", DebugStrings.toStringImpl(unenforced))); } if (!DebugStrings.isDefaultValue(constraintName)) { fields.add(new DebugStringField("constraint_name", DebugStrings.toStringImpl(constraintName))); } if (!DebugStrings.isDefaultValue(columnNameList)) { fields.add(new DebugStringField("column_name_list", DebugStrings.toStringCommaSeparated(columnNameList))); } } } /** * 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). * *

provides the names for the foreign key's * referencing columns. */ public static final class ResolvedForeignKey extends ResolvedConstraint { 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; private final ImmutableList referencingColumnList; ResolvedForeignKey(ResolvedForeignKeyProto proto, AbstractDeserializationHelper 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(); referencingColumnList = ImmutableList.copyOf(proto.getReferencingColumnListList()); } ResolvedForeignKey( String constraintName, ImmutableList referencingColumnOffsetList, Table referencedTable, ImmutableList referencedColumnOffsetList, MatchMode matchMode, ActionOperation updateAction, ActionOperation deleteAction, boolean enforced, ImmutableList optionList, ImmutableList referencingColumnList) { super(); this.constraintName = constraintName; this.referencingColumnOffsetList = referencingColumnOffsetList; this.referencedTable = referencedTable; this.referencedColumnOffsetList = referencedColumnOffsetList; this.matchMode = matchMode; this.updateAction = updateAction; this.deleteAction = deleteAction; this.enforced = enforced; this.optionList = optionList; this.referencingColumnList = referencingColumnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.constraintName = this.getConstraintName(); builder.referencingColumnOffsetList = this.getReferencingColumnOffsetList(); builder.referencedTable = this.getReferencedTable(); builder.referencedColumnOffsetList = this.getReferencedColumnOffsetList(); builder.matchMode = this.getMatchMode(); builder.updateAction = this.getUpdateAction(); builder.deleteAction = this.getDeleteAction(); builder.enforced = this.getEnforced(); builder.optionList = this.getOptionList(); builder.referencingColumnList = this.getReferencingColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedConstraint.Builder { protected String constraintName = null; protected ImmutableList referencingColumnOffsetList = null; protected Table referencedTable = null; protected ImmutableList referencedColumnOffsetList = null; protected MatchMode matchMode = null; protected ActionOperation updateAction = null; protected ActionOperation deleteAction = null; protected Boolean enforced = null; protected ImmutableList optionList = null; protected ImmutableList referencingColumnList = null; private Builder() {} @CanIgnoreReturnValue public Builder setConstraintName(String v) { this.constraintName = v; Preconditions.checkNotNull(v, "constraintName must not be null"); return this; } @CanIgnoreReturnValue public Builder setReferencingColumnOffsetList(List v) { this.referencingColumnOffsetList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setReferencedTable(Table v) { this.referencedTable = v; Preconditions.checkNotNull(v, "referencedTable must not be null"); return this; } @CanIgnoreReturnValue public Builder setReferencedColumnOffsetList(List v) { this.referencedColumnOffsetList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setMatchMode(MatchMode v) { this.matchMode = v; Preconditions.checkNotNull(v, "matchMode must not be null"); return this; } @CanIgnoreReturnValue public Builder setUpdateAction(ActionOperation v) { this.updateAction = v; Preconditions.checkNotNull(v, "updateAction must not be null"); return this; } @CanIgnoreReturnValue public Builder setDeleteAction(ActionOperation v) { this.deleteAction = v; Preconditions.checkNotNull(v, "deleteAction must not be null"); return this; } @CanIgnoreReturnValue public Builder setEnforced(boolean v) { this.enforced = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setReferencingColumnList(List v) { this.referencingColumnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedForeignKey build() { validate(); return new ResolvedForeignKey( constraintName, referencingColumnOffsetList, referencedTable, referencedColumnOffsetList, matchMode, updateAction, deleteAction, enforced, optionList, referencingColumnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( constraintName != null, "constraintName must be set"); Preconditions.checkArgument( referencingColumnOffsetList != null, "referencingColumnOffsetList must be set"); Preconditions.checkArgument( referencedTable != null, "referencedTable must be set"); Preconditions.checkArgument( referencedColumnOffsetList != null, "referencedColumnOffsetList must be set"); Preconditions.checkArgument( matchMode != null, "matchMode must be set"); Preconditions.checkArgument( updateAction != null, "updateAction must be set"); Preconditions.checkArgument( deleteAction != null, "deleteAction must be set"); Preconditions.checkArgument( enforced != null, "enforced must be set"); Preconditions.checkArgument( optionList != null, "optionList must be set"); } } public static final ResolvedForeignKey deserialize( ResolvedForeignKeyProto proto, AbstractDeserializationHelper 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 AnyResolvedConstraintProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedConstraintProto.Builder builder = AnyResolvedConstraintProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedConstraintProto.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, AnyResolvedConstraintProto.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. ResolvedConstraintProto parent = (ResolvedConstraintProto) 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()); } // referencingColumnList 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.addAllReferencingColumnList(this.getReferencingColumnList()); } 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; } public final ImmutableList getReferencingColumnList() { return referencingColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedForeignKey accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public 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)); } if (!DebugStrings.isDefaultValue(referencingColumnList)) { fields.add(new DebugStringField("referencing_column_list", DebugStrings.toStringImpl(referencingColumnList))); } } } /** * This represents the ABSL_CHECK constraint on a table. It is of the form: * * CONSTRAINT * ABSL_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 ResolvedConstraint { private final String constraintName; private final ResolvedExpr expression; private final boolean enforced; private final ImmutableList optionList; ResolvedCheckConstraint(ResolvedCheckConstraintProto proto, AbstractDeserializationHelper 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(); } ResolvedCheckConstraint( String constraintName, ResolvedExpr expression, boolean enforced, ImmutableList optionList) { super(); this.constraintName = constraintName; this.expression = expression; this.enforced = enforced; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.constraintName = this.getConstraintName(); builder.expression = this.getExpression(); builder.enforced = this.getEnforced(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedConstraint.Builder { protected String constraintName = null; protected ResolvedExpr expression = null; protected Boolean enforced = null; protected ImmutableList optionList = null; private Builder() {} @CanIgnoreReturnValue public Builder setConstraintName(String v) { this.constraintName = v; Preconditions.checkNotNull(v, "constraintName must not be null"); return this; } @CanIgnoreReturnValue public Builder setExpression(ResolvedExpr v) { this.expression = v; Preconditions.checkNotNull(v, "expression must not be null"); return this; } @CanIgnoreReturnValue public Builder setEnforced(boolean v) { this.enforced = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCheckConstraint build() { validate(); return new ResolvedCheckConstraint( constraintName, expression, enforced, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( constraintName != null, "constraintName must be set"); Preconditions.checkArgument( expression != null, "expression must be set"); Preconditions.checkArgument( enforced != null, "enforced must be set"); Preconditions.checkArgument( optionList != null, "optionList must be set"); } } public static final ResolvedCheckConstraint deserialize( ResolvedCheckConstraintProto proto, AbstractDeserializationHelper 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 AnyResolvedConstraintProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedConstraintProto.Builder builder = AnyResolvedConstraintProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedConstraintProto.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, AnyResolvedConstraintProto.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. ResolvedConstraintProto parent = (ResolvedConstraintProto) 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 public ResolvedCheckConstraint accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); visitor.descend(optionList); } public 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 (and other places) to provide a * user-visible name for each output column, and to map from * physical ResolvedColumns to user-visible output columns. */ public static final class ResolvedOutputColumn extends ResolvedArgument { private final String name; private final ResolvedColumn column; ResolvedOutputColumn(ResolvedOutputColumnProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); column = helper.deserialize(proto.getColumn()); } ResolvedOutputColumn( String name, ResolvedColumn column) { super(); this.name = name; this.column = column; } @Override public Builder toBuilder() { Builder builder = builder(); builder.name = this.getName(); builder.column = this.getColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String name = null; protected ResolvedColumn column = null; private Builder() {} @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; return this; } @CanIgnoreReturnValue public Builder setColumn(ResolvedColumn v) { this.column = v; Preconditions.checkNotNull(v, "column must not be null"); return this; } @Override public final ResolvedOutputColumn build() { validate(); return new ResolvedOutputColumn( name, column); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( column != null, "column must be set"); } } public static final ResolvedOutputColumn deserialize( ResolvedOutputColumnProto proto, AbstractDeserializationHelper 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 public ResolvedOutputColumn accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * This describes the output schema for table, like what is produced for * a query statement. * *

maps the physical ResolvedColumns available to * the user-visible column names that are returned, with their actual * column names. There may be duplicate names, and multiple output columns * may reference the same physical ResolvedColumn. * The list must be non-empty, since all output tables must have at least * one column. * *

This node is used in some places, while many other older nodes just * have these two fields inlined into a parent object. * Ideally, all those cases could be migrated to use ResolvedOutputSchema. */ public static final class ResolvedOutputSchema extends ResolvedArgument { 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; ResolvedOutputSchema(ResolvedOutputSchemaProto proto, AbstractDeserializationHelper 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(); } ResolvedOutputSchema( ImmutableList outputColumnList, boolean isValueTable) { super(); this.outputColumnList = outputColumnList; this.isValueTable = isValueTable; } @Override public Builder toBuilder() { Builder builder = builder(); builder.outputColumnList = this.getOutputColumnList(); builder.isValueTable = this.getIsValueTable(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList outputColumnList = null; protected Boolean isValueTable = null; private Builder() {} @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } /** * 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). */ @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { this.isValueTable = v; return this; } @Override public final ResolvedOutputSchema build() { validate(); return new ResolvedOutputSchema( outputColumnList, isValueTable); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( outputColumnList != null, "outputColumnList must be set"); } } public static final ResolvedOutputSchema deserialize( ResolvedOutputSchemaProto proto, AbstractDeserializationHelper helper) { return new ResolvedOutputSchema(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_OUTPUT_SCHEMA; } @Override public final String nodeKindString() { return "OutputSchema"; } /** * 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(); ResolvedOutputSchemaProto.Builder childBuilder = ResolvedOutputSchemaProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedOutputSchemaNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedOutputSchemaProto.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, ResolvedOutputSchemaProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) 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()); } 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; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedOutputSchema accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(outputColumnList); } public 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))); } } } /** * 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; ResolvedProjectScan(ResolvedProjectScanProto proto, AbstractDeserializationHelper 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; } } ResolvedProjectScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ImmutableList exprList, ResolvedScan inputScan) { super( columnList, hintList, isOrdered, nodeSource); this.exprList = exprList; this.inputScan = inputScan; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.exprList = this.getExprList(); builder.inputScan = this.getInputScan(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ImmutableList exprList = null; protected ResolvedScan inputScan = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setExprList(List v) { this.exprList = ImmutableList.copyOf(v); return this; } /** * Note: this method propagates the 'isOrdered' field from {@param v}. * To override this, call setIsOrdered explicitly after calling this * method. */ @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); setIsOrdered(v.getIsOrdered()); return this; } @Override public final ResolvedProjectScan build() { validate(); return new ResolvedProjectScan( columnList, hintList, isOrdered, nodeSource, exprList, inputScan); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( exprList != null, "exprList must be set"); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); } } public static final ResolvedProjectScan deserialize( ResolvedProjectScanProto proto, AbstractDeserializationHelper 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 public ResolvedProjectScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(exprList); visitor.descend(inputScan); } public 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 * ResolvedFunctionArgument 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. * *

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.) * Pruning has no effect on value tables (the value is never pruned). * *

is a set of new ResolvedColumns created by this scan. * The [i] should be matched to the related TVFScan's output * relation column by * .result_schema().column([i]). * *

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 concrete arguments for this TVF * call, including the default values or NULLs injected for * the omitted arguments (Note the NULL injection is a * temporary solution to handle omitted named arguments. This * is subject to change by upcoming CLs). * *

This list matches 1-1 with the , and * identifies the index of the corresponding column in the 's * result relation column list. * *

The AS alias for the scan, or empty if none. * The FunctionSignature object from the * signatures()> list that matched the * current call. The TVFScan's * list * matches 1:1 to , while its * list still has * the full argument list. * The analyzer only sets this field when * it could be ambiguous for an engine to figure * out the actual arguments provided, e.g., when * there are arguments omitted from the call. When * it is provided, engines may use this object to * check for the argument names and omitted * arguments. SQLBuilder may also need this object * in cases when the named argument notation is * required for this call. */ public static final class ResolvedTVFScan extends ResolvedScan { private final TableValuedFunction tvf; private final TVFSignature signature; private final ImmutableList argumentList; private final ImmutableList columnIndexList; private final String alias; private final FunctionSignature functionCallSignature; ResolvedTVFScan(ResolvedTVFScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); tvf = helper.deserialize(proto.getTvf()); signature = helper.deserialize(proto.getSignature()); ImmutableList.Builder argumentListBuilder = ImmutableList.builder(); for (ResolvedFunctionArgumentProto element : proto.getArgumentListList()) { argumentListBuilder .add(ResolvedFunctionArgument.deserialize(element, helper)); } argumentList = argumentListBuilder.build(); columnIndexList = ImmutableList.copyOf(proto.getColumnIndexListList()); alias = proto.getAlias(); if (proto.hasFunctionCallSignature()) { functionCallSignature = helper.deserialize(proto.getFunctionCallSignature()); } else { functionCallSignature = null; } } ResolvedTVFScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, TableValuedFunction tvf, TVFSignature signature, ImmutableList argumentList, ImmutableList columnIndexList, String alias, FunctionSignature functionCallSignature) { super( columnList, hintList, isOrdered, nodeSource); this.tvf = tvf; this.signature = signature; this.argumentList = argumentList; this.columnIndexList = columnIndexList; this.alias = alias; this.functionCallSignature = functionCallSignature; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.tvf = this.getTvf(); builder.signature = this.getSignature(); builder.argumentList = this.getArgumentList(); builder.columnIndexList = this.getColumnIndexList(); builder.alias = this.getAlias(); builder.functionCallSignature = this.getFunctionCallSignature(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected TableValuedFunction tvf = null; protected TVFSignature signature = null; protected ImmutableList argumentList = null; protected ImmutableList columnIndexList = null; protected String alias = null; protected FunctionSignature functionCallSignature = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setTvf(TableValuedFunction v) { this.tvf = v; Preconditions.checkNotNull(v, "tvf must not be null"); return this; } @CanIgnoreReturnValue public Builder setSignature(TVFSignature v) { this.signature = v; Preconditions.checkNotNull(v, "signature must not be null"); return this; } @CanIgnoreReturnValue public Builder setArgumentList(List v) { this.argumentList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setColumnIndexList(List v) { this.columnIndexList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setAlias(String v) { this.alias = v; return this; } @CanIgnoreReturnValue public Builder setFunctionCallSignature(FunctionSignature v) { this.functionCallSignature = v; return this; } @Override public final ResolvedTVFScan build() { validate(); return new ResolvedTVFScan( columnList, hintList, isOrdered, nodeSource, tvf, signature, argumentList, columnIndexList, alias, functionCallSignature); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( tvf != null, "tvf must be set"); Preconditions.checkArgument( signature != null, "signature must be set"); Preconditions.checkArgument( argumentList != null, "argumentList must be set"); } } public static final ResolvedTVFScan deserialize( ResolvedTVFScanProto proto, AbstractDeserializationHelper 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 (ResolvedFunctionArgument element : argumentLists) { ResolvedFunctionArgumentProto.Builder argumentListBuilder = ResolvedFunctionArgumentProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, argumentListBuilder); proto.addArgumentList(argumentListBuilder.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()); // functionCallSignature is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getFunctionCallSignature() != null) { proto.setFunctionCallSignature( ResolvedNodes.serialize(this.getFunctionCallSignature(), fileDescriptorSetsBuilder)); } } public final TableValuedFunction getTvf() { return tvf; } public final TVFSignature getSignature() { return signature; } public final ImmutableList getArgumentList() { return argumentList; } public final ImmutableList getColumnIndexList() { return columnIndexList; } public final String getAlias() { return alias; } public final FunctionSignature getFunctionCallSignature() { return functionCallSignature; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedTVFScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(argumentList); } public 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(columnIndexList)) { fields.add(new DebugStringField("column_index_list", DebugStrings.toStringCommaSeparatedForInt(columnIndexList))); } if (!DebugStrings.isDefaultValue(alias)) { fields.add(new DebugStringField("alias", DebugStrings.toStringImpl(alias))); } if (!DebugStrings.isDefaultValue(functionCallSignature)) { fields.add(new DebugStringField("function_call_signature", DebugStrings.toStringImpl(functionCallSignature))); } } } /** * ResolvedGroupRowsScan represents a call to a special TVF GROUP_ROWS(). * It can only show up inside WITH GROUP ROWS clause, which is resolved as * the field with_group_rows_subquery in ResolvedNonScalarFunctionCallBase * ResolvedGroupRowsScan. This scan produces rows corresponding to the input * of ResolvedAggregateScan that belong to the current group. * *

is a list of new columns created to store values * coming from the input of the aggregate scan. ResolvedComputedColumn can * only hold ResolvedColumnRef's and can reference anything from the * pre-aggregation scan. * *

is the alias of the scan or empty if none. */ public static final class ResolvedGroupRowsScan extends ResolvedScan { private final ImmutableList inputColumnList; private final String alias; ResolvedGroupRowsScan(ResolvedGroupRowsScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder inputColumnListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getInputColumnListList()) { inputColumnListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } inputColumnList = inputColumnListBuilder.build(); alias = proto.getAlias(); } ResolvedGroupRowsScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ImmutableList inputColumnList, String alias) { super( columnList, hintList, isOrdered, nodeSource); this.inputColumnList = inputColumnList; this.alias = alias; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputColumnList = this.getInputColumnList(); builder.alias = this.getAlias(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ImmutableList inputColumnList = null; protected String alias = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputColumnList(List v) { this.inputColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setAlias(String v) { this.alias = v; return this; } @Override public final ResolvedGroupRowsScan build() { validate(); return new ResolvedGroupRowsScan( columnList, hintList, isOrdered, nodeSource, inputColumnList, alias); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputColumnList != null, "inputColumnList must be set"); } } public static final ResolvedGroupRowsScan deserialize( ResolvedGroupRowsScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedGroupRowsScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GROUP_ROWS_SCAN; } @Override public final String nodeKindString() { return "GroupRowsScan"; } /** * 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(); ResolvedGroupRowsScanProto.Builder childBuilder = ResolvedGroupRowsScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGroupRowsScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGroupRowsScanProto.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, ResolvedGroupRowsScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList inputColumnLists = this.getInputColumnList(); for (ResolvedComputedColumn element : inputColumnLists) { ResolvedComputedColumnProto.Builder inputColumnListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, inputColumnListBuilder); proto.addInputColumnList(inputColumnListBuilder.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 ImmutableList getInputColumnList() { return inputColumnList; } public final String getAlias() { return alias; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGroupRowsScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputColumnList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!inputColumnList.isEmpty()) { fields.add(new DebugStringField("input_column_list", inputColumnList)); } if (!DebugStrings.isDefaultValue(alias)) { fields.add(new DebugStringField("alias", DebugStrings.toStringImpl(alias))); } } } /** * This represents a generic argument to a function. The argument can be * semantically an expression, relation, model, connection descriptor, or * sequence. * *

The following fields are mutally exclusive: * * `expr` represents a scalar function argument. * * `scan` represents a table-typed argument. * * `model` represents a ML model function argument. * * `connection` represents a connection object function argument. * * `descriptor_arg` represents a descriptor object function argument. * * `inline_lambda` represents a lambda function argument. * * `sequence` represents a sequence object function argument. * *

This node could be used in multiple places: * * ResolvedTVFScan supports all of these. * * ResolvedFunctionCall supports `expr`, `inline_lambda`, and `sequence`. * * ResolvedCallStmt supports only `expr`. * *

If the argument has type `scan`, `argument_column_list` maps columns from * `scan` into specific columns of the argument's input schema, matching * those columns positionally. i.e. `scan`'s column_list may have fewer * columns or out-of-order columns, and this vector maps those columns into * specific input columns. * *

Some arguments may also have an alias, stored in the `argument_alias` * field, which is not mutally exclusive with the fields above. */ public static final class ResolvedFunctionArgument extends ResolvedArgument { private final ResolvedExpr expr; private final ResolvedScan scan; private final ResolvedModel model; private final ResolvedConnection connection; private final ResolvedDescriptor descriptorArg; private final ImmutableList argumentColumnList; private final ResolvedInlineLambda inlineLambda; private final ResolvedSequence sequence; /** * Stores the alias of the argument, either provided by the user or * generated by the resolver. This can only be populated if allowed * by `FunctionArgumentTypeOptions::argument_alias_kind`. * *

An argument alias is an identifier associated with a function * argument in the form of F( AS ), where is the * argument alias for the function argument . * *

Examples include * * STRUCT(1 AS x, 2 AS y) * * ARRAY_ZIP(arr1 AS a, arr2 AS b) * where the argument alias is used as a field name in an output * STRUCT value. For dynamic types like JSON, these aliases may be * used at run-time. * *

This field will be empty if the argument does not support aliases, * or an alias could not be inferred. * *

The current implementation only allows an argument to have an * alias if its type is `expr`, but the support may be extended to * other types, e.g. `scan` or `model` in the future. */ private final String argumentAlias; ResolvedFunctionArgument(ResolvedFunctionArgumentProto proto, AbstractDeserializationHelper 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; } if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } if (proto.hasDescriptorArg()) { descriptorArg = ResolvedDescriptor.deserialize(proto.getDescriptorArg(), helper); } else { descriptorArg = null; } ImmutableList.Builder argumentColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getArgumentColumnListList()) { argumentColumnListBuilder.add(helper.deserialize(element)); } argumentColumnList = argumentColumnListBuilder.build(); if (proto.hasInlineLambda()) { inlineLambda = ResolvedInlineLambda.deserialize(proto.getInlineLambda(), helper); } else { inlineLambda = null; } if (proto.hasSequence()) { sequence = ResolvedSequence.deserialize(proto.getSequence(), helper); } else { sequence = null; } argumentAlias = proto.getArgumentAlias(); } ResolvedFunctionArgument( ResolvedExpr expr, ResolvedScan scan, ResolvedModel model, ResolvedConnection connection, ResolvedDescriptor descriptorArg, ImmutableList argumentColumnList, ResolvedInlineLambda inlineLambda, ResolvedSequence sequence, String argumentAlias) { super(); this.expr = expr; this.scan = scan; this.model = model; this.connection = connection; this.descriptorArg = descriptorArg; this.argumentColumnList = argumentColumnList; this.inlineLambda = inlineLambda; this.sequence = sequence; this.argumentAlias = argumentAlias; } @Override public Builder toBuilder() { Builder builder = builder(); builder.expr = this.getExpr(); builder.scan = this.getScan(); builder.model = this.getModel(); builder.connection = this.getConnection(); builder.descriptorArg = this.getDescriptorArg(); builder.argumentColumnList = this.getArgumentColumnList(); builder.inlineLambda = this.getInlineLambda(); builder.sequence = this.getSequence(); builder.argumentAlias = this.getArgumentAlias(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr expr = null; protected ResolvedScan scan = null; protected ResolvedModel model = null; protected ResolvedConnection connection = null; protected ResolvedDescriptor descriptorArg = null; protected ImmutableList argumentColumnList = null; protected ResolvedInlineLambda inlineLambda = null; protected ResolvedSequence sequence = null; protected String argumentAlias = ""; private Builder() {} @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; return this; } @CanIgnoreReturnValue public Builder setScan(ResolvedScan v) { this.scan = v; return this; } @CanIgnoreReturnValue public Builder setModel(ResolvedModel v) { this.model = v; return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @CanIgnoreReturnValue public Builder setDescriptorArg(ResolvedDescriptor v) { this.descriptorArg = v; return this; } @CanIgnoreReturnValue public Builder setArgumentColumnList(List v) { this.argumentColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setInlineLambda(ResolvedInlineLambda v) { this.inlineLambda = v; return this; } @CanIgnoreReturnValue public Builder setSequence(ResolvedSequence v) { this.sequence = v; return this; } /** * Stores the alias of the argument, either provided by the user or * generated by the resolver. This can only be populated if allowed * by `FunctionArgumentTypeOptions::argument_alias_kind`. * *

An argument alias is an identifier associated with a function * argument in the form of F( AS ), where is the * argument alias for the function argument . * *

Examples include * * STRUCT(1 AS x, 2 AS y) * * ARRAY_ZIP(arr1 AS a, arr2 AS b) * where the argument alias is used as a field name in an output * STRUCT value. For dynamic types like JSON, these aliases may be * used at run-time. * *

This field will be empty if the argument does not support aliases, * or an alias could not be inferred. * *

The current implementation only allows an argument to have an * alias if its type is `expr`, but the support may be extended to * other types, e.g. `scan` or `model` in the future. */ @CanIgnoreReturnValue public Builder setArgumentAlias(String v) { this.argumentAlias = v; return this; } @Override public final ResolvedFunctionArgument build() { validate(); return new ResolvedFunctionArgument( expr, scan, model, connection, descriptorArg, argumentColumnList, inlineLambda, sequence, argumentAlias); } @Override protected void validate() { super.validate(); } } public static final ResolvedFunctionArgument deserialize( ResolvedFunctionArgumentProto proto, AbstractDeserializationHelper helper) { return new ResolvedFunctionArgument(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_FUNCTION_ARGUMENT; } @Override public final String nodeKindString() { return "FunctionArgument"; } /** * 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(); ResolvedFunctionArgumentProto.Builder childBuilder = ResolvedFunctionArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedFunctionArgumentNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedFunctionArgumentProto.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, ResolvedFunctionArgumentProto.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()); } // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.build()); } // descriptorArg is an AST node. Call its serialization chain. if (this.getDescriptorArg() != null) { ResolvedDescriptorProto.Builder descriptorArgBuilder = ResolvedDescriptorProto.newBuilder(); this.getDescriptorArg().serialize( fileDescriptorSetsBuilder, descriptorArgBuilder); proto.setDescriptorArg( descriptorArgBuilder.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)); } // inlineLambda is an AST node. Call its serialization chain. if (this.getInlineLambda() != null) { ResolvedInlineLambdaProto.Builder inlineLambdaBuilder = ResolvedInlineLambdaProto.newBuilder(); this.getInlineLambda().serialize( fileDescriptorSetsBuilder, inlineLambdaBuilder); proto.setInlineLambda( inlineLambdaBuilder.build()); } // sequence is an AST node. Call its serialization chain. if (this.getSequence() != null) { ResolvedSequenceProto.Builder sequenceBuilder = ResolvedSequenceProto.newBuilder(); this.getSequence().serialize( fileDescriptorSetsBuilder, sequenceBuilder); proto.setSequence( sequenceBuilder.build()); } // argumentAlias is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setArgumentAlias(this.getArgumentAlias()); } public final ResolvedExpr getExpr() { return expr; } public final ResolvedScan getScan() { return scan; } public final ResolvedModel getModel() { return model; } public final ResolvedConnection getConnection() { return connection; } public final ResolvedDescriptor getDescriptorArg() { return descriptorArg; } public final ImmutableList getArgumentColumnList() { return argumentColumnList; } public final ResolvedInlineLambda getInlineLambda() { return inlineLambda; } public final ResolvedSequence getSequence() { return sequence; } /** * Stores the alias of the argument, either provided by the user or * generated by the resolver. This can only be populated if allowed * by `FunctionArgumentTypeOptions::argument_alias_kind`. * *

An argument alias is an identifier associated with a function * argument in the form of F( AS ), where is the * argument alias for the function argument . * *

Examples include * * STRUCT(1 AS x, 2 AS y) * * ARRAY_ZIP(arr1 AS a, arr2 AS b) * where the argument alias is used as a field name in an output * STRUCT value. For dynamic types like JSON, these aliases may be * used at run-time. * *

This field will be empty if the argument does not support aliases, * or an alias could not be inferred. * *

The current implementation only allows an argument to have an * alias if its type is `expr`, but the support may be extended to * other types, e.g. `scan` or `model` in the future. */ public final String getArgumentAlias() { return argumentAlias; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedFunctionArgument accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); visitor.descend(scan); visitor.descend(model); visitor.descend(connection); visitor.descend(descriptorArg); visitor.descend(inlineLambda); visitor.descend(sequence); } public 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 (connection != null) { fields.add(new DebugStringField("connection", connection)); } if (descriptorArg != null) { fields.add(new DebugStringField("descriptor_arg", descriptorArg)); } if (!DebugStrings.isDefaultValue(argumentColumnList)) { fields.add(new DebugStringField("argument_column_list", DebugStrings.toStringImpl(argumentColumnList))); } if (inlineLambda != null) { fields.add(new DebugStringField("inline_lambda", inlineLambda)); } if (sequence != null) { fields.add(new DebugStringField("sequence", sequence)); } if (!DebugStrings.isDefaultValue(argumentAlias)) { fields.add(new DebugStringField("argument_alias", DebugStrings.toStringImpl(argumentAlias))); } } } /** * The superclass of all ZetaSQL statements. */ public static abstract class ResolvedStatement extends ResolvedNode { private final ImmutableList hintList; ResolvedStatement(ResolvedStatementProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder hintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getHintListList()) { hintListBuilder .add(ResolvedOption.deserialize(element, helper)); } hintList = hintListBuilder.build(); } ResolvedStatement( ImmutableList hintList) { super(); this.hintList = hintList; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedNode.Builder { protected ImmutableList hintList = ImmutableList.of(); private Builder() {} @CanIgnoreReturnValue public Builder setHintList(List v) { this.hintList = ImmutableList.copyOf(v); return this; } @Override public abstract ResolvedStatement build(); @Override protected void validate() { super.validate(); } } public static ResolvedStatement deserialize( AnyResolvedStatementProto proto, AbstractDeserializationHelper 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); case RESOLVED_EXECUTE_IMMEDIATE_STMT_NODE: return ResolvedExecuteImmediateStmt.deserialize( proto.getResolvedExecuteImmediateStmtNode(), helper); case RESOLVED_ASSIGNMENT_STMT_NODE: return ResolvedAssignmentStmt.deserialize( proto.getResolvedAssignmentStmtNode(), helper); case RESOLVED_EXPORT_MODEL_STMT_NODE: return ResolvedExportModelStmt.deserialize( proto.getResolvedExportModelStmtNode(), helper); case RESOLVED_DROP_TABLE_FUNCTION_STMT_NODE: return ResolvedDropTableFunctionStmt.deserialize( proto.getResolvedDropTableFunctionStmtNode(), helper); case RESOLVED_CLONE_DATA_STMT_NODE: return ResolvedCloneDataStmt.deserialize( proto.getResolvedCloneDataStmtNode(), helper); case RESOLVED_ANALYZE_STMT_NODE: return ResolvedAnalyzeStmt.deserialize( proto.getResolvedAnalyzeStmtNode(), helper); case RESOLVED_DROP_SNAPSHOT_TABLE_STMT_NODE: return ResolvedDropSnapshotTableStmt.deserialize( proto.getResolvedDropSnapshotTableStmtNode(), helper); case RESOLVED_AUX_LOAD_DATA_STMT_NODE: return ResolvedAuxLoadDataStmt.deserialize( proto.getResolvedAuxLoadDataStmtNode(), helper); case RESOLVED_DROP_PRIVILEGE_RESTRICTION_STMT_NODE: return ResolvedDropPrivilegeRestrictionStmt.deserialize( proto.getResolvedDropPrivilegeRestrictionStmtNode(), helper); case RESOLVED_UNDROP_STMT_NODE: return ResolvedUndropStmt.deserialize( proto.getResolvedUndropStmtNode(), helper); case RESOLVED_EXPORT_METADATA_STMT_NODE: return ResolvedExportMetadataStmt.deserialize( proto.getResolvedExportMetadataStmtNode(), helper); case RESOLVED_DROP_INDEX_STMT_NODE: return ResolvedDropIndexStmt.deserialize( proto.getResolvedDropIndexStmtNode(), helper); case RESOLVED_GENERALIZED_QUERY_STMT_NODE: return ResolvedGeneralizedQueryStmt.deserialize( proto.getResolvedGeneralizedQueryStmtNode(), 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 public abstract ResolvedStatement accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(hintList); } public 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; ResolvedExplainStmt(ResolvedExplainStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasStatement()) { statement = ResolvedStatement.deserialize(proto.getStatement(), helper); } else { statement = null; } } ResolvedExplainStmt( ImmutableList hintList, ResolvedStatement statement) { super( hintList); this.statement = statement; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.statement = this.getStatement(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedStatement statement = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setStatement(ResolvedStatement v) { this.statement = v; Preconditions.checkNotNull(v, "statement must not be null"); return this; } @Override public final ResolvedExplainStmt build() { validate(); return new ResolvedExplainStmt( hintList, statement); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( statement != null, "statement must be set"); } } public static final ResolvedExplainStmt deserialize( ResolvedExplainStmtProto proto, AbstractDeserializationHelper 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 public ResolvedExplainStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(statement); } public 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; ResolvedQueryStmt(ResolvedQueryStmtProto proto, AbstractDeserializationHelper 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; } } ResolvedQueryStmt( ImmutableList hintList, ImmutableList outputColumnList, boolean isValueTable, ResolvedScan query) { super( hintList); this.outputColumnList = outputColumnList; this.isValueTable = isValueTable; this.query = query; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.outputColumnList = this.getOutputColumnList(); builder.isValueTable = this.getIsValueTable(); builder.query = this.getQuery(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ImmutableList outputColumnList = null; protected Boolean isValueTable = null; protected ResolvedScan query = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } /** * 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). */ @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { this.isValueTable = v; return this; } @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; Preconditions.checkNotNull(v, "query must not be null"); return this; } @Override public final ResolvedQueryStmt build() { validate(); return new ResolvedQueryStmt( hintList, outputColumnList, isValueTable, query); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( outputColumnList != null, "outputColumnList must be set"); Preconditions.checkArgument( query != null, "query must be set"); } } public static final ResolvedQueryStmt deserialize( ResolvedQueryStmtProto proto, AbstractDeserializationHelper 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 public ResolvedQueryStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(outputColumnList); visitor.descend(query); } public 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 is a query statement variation that supports generalized queries * using operators that might not produce exactly one query result. * Queries using these operators can produce multiple output tables, or zero * output tables, and can also have statement side-effects like DML actions. * *

This is used for any query containing pipe syntax operators like FORK * (that splits the query into multiple output tables) or terminal operators * like CREATE TABLE (that consume the output without returning a table). * See (broken link). * *

This node can only occur if: * * FEATURE_PIPES is enabled, * * Some pipe operator that produces generalized output is enabled, * * One of those operators occurs in the query, and * * ResolvedGeneralizedQueryStmt is in SupportedStatementKinds in * LanguageOptions. * *

`output_schema` is nullable, and will be null if the outer `query` * doesn't return a table. * *

Additional output tables or statement side-effects can be found * while traversing `query`, looking at ResolvedGeneralizedQuerySubpipeline * nodes. */ public static final class ResolvedGeneralizedQueryStmt extends ResolvedStatement { private final ResolvedOutputSchema outputSchema; private final ResolvedScan query; ResolvedGeneralizedQueryStmt(ResolvedGeneralizedQueryStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasOutputSchema()) { outputSchema = ResolvedOutputSchema.deserialize(proto.getOutputSchema(), helper); } else { outputSchema = null; } if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } } ResolvedGeneralizedQueryStmt( ImmutableList hintList, ResolvedOutputSchema outputSchema, ResolvedScan query) { super( hintList); this.outputSchema = outputSchema; this.query = query; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.outputSchema = this.getOutputSchema(); builder.query = this.getQuery(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedOutputSchema outputSchema = null; protected ResolvedScan query = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setOutputSchema(ResolvedOutputSchema v) { this.outputSchema = v; Preconditions.checkNotNull(v, "outputSchema must not be null"); return this; } @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; Preconditions.checkNotNull(v, "query must not be null"); return this; } @Override public final ResolvedGeneralizedQueryStmt build() { validate(); return new ResolvedGeneralizedQueryStmt( hintList, outputSchema, query); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( outputSchema != null, "outputSchema must be set"); Preconditions.checkArgument( query != null, "query must be set"); } } public static final ResolvedGeneralizedQueryStmt deserialize( ResolvedGeneralizedQueryStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedGeneralizedQueryStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GENERALIZED_QUERY_STMT; } @Override public final String nodeKindString() { return "GeneralizedQueryStmt"; } /** * 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(); ResolvedGeneralizedQueryStmtProto.Builder childBuilder = ResolvedGeneralizedQueryStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGeneralizedQueryStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGeneralizedQueryStmtProto.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, ResolvedGeneralizedQueryStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // outputSchema is an AST node. Call its serialization chain. if (this.getOutputSchema() != null) { ResolvedOutputSchemaProto.Builder outputSchemaBuilder = ResolvedOutputSchemaProto.newBuilder(); this.getOutputSchema().serialize( fileDescriptorSetsBuilder, outputSchemaBuilder); proto.setOutputSchema( outputSchemaBuilder.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 ResolvedOutputSchema getOutputSchema() { return outputSchema; } public final ResolvedScan getQuery() { return query; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGeneralizedQueryStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(outputSchema); visitor.descend(query); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (outputSchema != null) { fields.add(new DebugStringField("output_schema", outputSchema)); } 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; ResolvedCreateDatabaseStmt(ResolvedCreateDatabaseStmtProto proto, AbstractDeserializationHelper 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(); } ResolvedCreateDatabaseStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList optionList) { super( hintList); this.namePath = namePath; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ImmutableList namePath = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCreateDatabaseStmt build() { validate(); return new ResolvedCreateDatabaseStmt( hintList, namePath, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedCreateDatabaseStmt deserialize( ResolvedCreateDatabaseStmtProto proto, AbstractDeserializationHelper 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 public ResolvedCreateDatabaseStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public 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; ResolvedCreateStatement(ResolvedCreateStatementProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); createScope = proto.getCreateScope(); createMode = proto.getCreateMode(); } ResolvedCreateStatement( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode) { super( hintList); this.namePath = namePath; this.createScope = createScope; this.createMode = createMode; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedStatement.Builder { protected ImmutableList namePath = null; protected CreateScope createScope = null; protected CreateMode createMode = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { this.createScope = v; return this; } @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { this.createMode = v; return this; } @Override public abstract ResolvedCreateStatement build(); @Override protected void validate() { super.validate(); } } public static ResolvedCreateStatement deserialize( AnyResolvedCreateStatementProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { 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); case RESOLVED_CREATE_ENTITY_STMT_NODE: return ResolvedCreateEntityStmt.deserialize( proto.getResolvedCreateEntityStmtNode(), helper); case RESOLVED_CREATE_SNAPSHOT_TABLE_STMT_NODE: return ResolvedCreateSnapshotTableStmt.deserialize( proto.getResolvedCreateSnapshotTableStmtNode(), helper); case RESOLVED_CREATE_PRIVILEGE_RESTRICTION_STMT_NODE: return ResolvedCreatePrivilegeRestrictionStmt.deserialize( proto.getResolvedCreatePrivilegeRestrictionStmtNode(), helper); case RESOLVED_CREATE_PROPERTY_GRAPH_STMT_NODE: return ResolvedCreatePropertyGraphStmt.deserialize( proto.getResolvedCreatePropertyGraphStmtNode(), helper); case RESOLVED_CREATE_SCHEMA_STMT_BASE_NODE: return ResolvedCreateSchemaStmtBase.deserialize( proto.getResolvedCreateSchemaStmtBaseNode(), helper); case RESOLVED_CREATE_CONNECTION_STMT_NODE: return ResolvedCreateConnectionStmt.deserialize( proto.getResolvedCreateConnectionStmtNode(), 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 public abstract ResolvedCreateStatement accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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. * *

`option_list` represents the per item options for the index. This is * used in both the case where ALL COLUMNS is used and the case where * specific items are specified. The list of options for a specific item * must not be empty in the case of ALL COLUMNS. */ public static final class ResolvedIndexItem extends ResolvedArgument { private final ResolvedColumnRef columnRef; private final boolean descending; private final ImmutableList optionList; ResolvedIndexItem(ResolvedIndexItemProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasColumnRef()) { columnRef = ResolvedColumnRef.deserialize(proto.getColumnRef(), helper); } else { columnRef = null; } descending = proto.getDescending(); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedIndexItem( ResolvedColumnRef columnRef, boolean descending, ImmutableList optionList) { super(); this.columnRef = columnRef; this.descending = descending; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnRef = this.getColumnRef(); builder.descending = this.getDescending(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedColumnRef columnRef = null; protected Boolean descending = null; protected ImmutableList optionList = null; private Builder() {} @CanIgnoreReturnValue public Builder setColumnRef(ResolvedColumnRef v) { this.columnRef = v; Preconditions.checkNotNull(v, "columnRef must not be null"); return this; } @CanIgnoreReturnValue public Builder setDescending(boolean v) { this.descending = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedIndexItem build() { validate(); return new ResolvedIndexItem( columnRef, descending, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( columnRef != null, "columnRef must be set"); Preconditions.checkArgument( descending != null, "descending must be set"); } } public static final ResolvedIndexItem deserialize( ResolvedIndexItemProto proto, AbstractDeserializationHelper 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()); // 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 ResolvedColumnRef getColumnRef() { return columnRef; } public final boolean getDescending() { return descending; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedIndexItem accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnRef); visitor.descend(optionList); } public 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))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * 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; ResolvedUnnestItem(ResolvedUnnestItemProto proto, AbstractDeserializationHelper 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; } } ResolvedUnnestItem( ResolvedExpr arrayExpr, ResolvedColumn elementColumn, ResolvedColumnHolder arrayOffsetColumn) { super(); this.arrayExpr = arrayExpr; this.elementColumn = elementColumn; this.arrayOffsetColumn = arrayOffsetColumn; } @Override public Builder toBuilder() { Builder builder = builder(); builder.arrayExpr = this.getArrayExpr(); builder.elementColumn = this.getElementColumn(); builder.arrayOffsetColumn = this.getArrayOffsetColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr arrayExpr = null; protected ResolvedColumn elementColumn = null; protected ResolvedColumnHolder arrayOffsetColumn = null; private Builder() {} @CanIgnoreReturnValue public Builder setArrayExpr(ResolvedExpr v) { this.arrayExpr = v; Preconditions.checkNotNull(v, "arrayExpr must not be null"); return this; } @CanIgnoreReturnValue public Builder setElementColumn(ResolvedColumn v) { this.elementColumn = v; Preconditions.checkNotNull(v, "elementColumn must not be null"); return this; } @CanIgnoreReturnValue public Builder setArrayOffsetColumn(ResolvedColumnHolder v) { this.arrayOffsetColumn = v; return this; } @Override public final ResolvedUnnestItem build() { validate(); return new ResolvedUnnestItem( arrayExpr, elementColumn, arrayOffsetColumn); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( arrayExpr != null, "arrayExpr must be set"); Preconditions.checkArgument( elementColumn != null, "elementColumn must be set"); } } public static final ResolvedUnnestItem deserialize( ResolvedUnnestItemProto proto, AbstractDeserializationHelper 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 public ResolvedUnnestItem accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(arrayExpr); visitor.descend(arrayOffsetColumn); } public 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] [SEARCH | VECTOR] INDEX [IF NOT EXISTS] * ON * [UNNEST(path_expression) [[AS] alias] [WITH OFFSET [[AS] alias]], ...] * (path_expression [ASC|DESC], ...) * [STORING (Expression, ...)] * [PARTITION BY partition_expression, ...] * [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. * specifies if the index is for search. It is mutually exclusive * with is_vector. * specifies if the index is for vector search. It is mutually * exclusive with is_search. * specifies if indexing all the columns of the table. * When this field is true, index_item_list must be * empty and is_search must be true. * 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 the expressions in the partition by 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 boolean isSearch; private final boolean isVector; private final boolean indexAllColumns; private final ImmutableList indexItemList; private final ImmutableList storingExpressionList; private final ImmutableList partitionByList; private final ImmutableList optionList; private final ImmutableList computedColumnsList; private final ImmutableList unnestExpressionsList; ResolvedCreateIndexStmt(ResolvedCreateIndexStmtProto proto, AbstractDeserializationHelper 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(); isSearch = proto.getIsSearch(); isVector = proto.getIsVector(); indexAllColumns = proto.getIndexAllColumns(); 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 partitionByListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getPartitionByListList()) { partitionByListBuilder .add(ResolvedExpr.deserialize(element, helper)); } partitionByList = partitionByListBuilder.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(); } ResolvedCreateIndexStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList tableNamePath, ResolvedTableScan tableScan, boolean isUnique, boolean isSearch, boolean isVector, boolean indexAllColumns, ImmutableList indexItemList, ImmutableList storingExpressionList, ImmutableList partitionByList, ImmutableList optionList, ImmutableList computedColumnsList, ImmutableList unnestExpressionsList) { super( hintList, namePath, createScope, createMode); this.tableNamePath = tableNamePath; this.tableScan = tableScan; this.isUnique = isUnique; this.isSearch = isSearch; this.isVector = isVector; this.indexAllColumns = indexAllColumns; this.indexItemList = indexItemList; this.storingExpressionList = storingExpressionList; this.partitionByList = partitionByList; this.optionList = optionList; this.computedColumnsList = computedColumnsList; this.unnestExpressionsList = unnestExpressionsList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.tableNamePath = this.getTableNamePath(); builder.tableScan = this.getTableScan(); builder.isUnique = this.getIsUnique(); builder.isSearch = this.getIsSearch(); builder.isVector = this.getIsVector(); builder.indexAllColumns = this.getIndexAllColumns(); builder.indexItemList = this.getIndexItemList(); builder.storingExpressionList = this.getStoringExpressionList(); builder.partitionByList = this.getPartitionByList(); builder.optionList = this.getOptionList(); builder.computedColumnsList = this.getComputedColumnsList(); builder.unnestExpressionsList = this.getUnnestExpressionsList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList tableNamePath = null; protected ResolvedTableScan tableScan = null; protected Boolean isUnique = null; protected boolean isSearch = false; protected boolean isVector = false; protected boolean indexAllColumns = false; protected ImmutableList indexItemList = null; protected ImmutableList storingExpressionList = null; protected ImmutableList partitionByList = null; protected ImmutableList optionList = null; protected ImmutableList computedColumnsList = null; protected ImmutableList unnestExpressionsList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setTableNamePath(List v) { this.tableNamePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setTableScan(ResolvedTableScan v) { this.tableScan = v; return this; } @CanIgnoreReturnValue public Builder setIsUnique(boolean v) { this.isUnique = v; return this; } @CanIgnoreReturnValue public Builder setIsSearch(boolean v) { this.isSearch = v; return this; } @CanIgnoreReturnValue public Builder setIsVector(boolean v) { this.isVector = v; return this; } @CanIgnoreReturnValue public Builder setIndexAllColumns(boolean v) { this.indexAllColumns = v; return this; } @CanIgnoreReturnValue public Builder setIndexItemList(List v) { this.indexItemList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setStoringExpressionList(List v) { this.storingExpressionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setPartitionByList(List v) { this.partitionByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setComputedColumnsList(List v) { this.computedColumnsList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setUnnestExpressionsList(List v) { this.unnestExpressionsList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCreateIndexStmt build() { validate(); return new ResolvedCreateIndexStmt( hintList, namePath, createScope, createMode, tableNamePath, tableScan, isUnique, isSearch, isVector, indexAllColumns, indexItemList, storingExpressionList, partitionByList, optionList, computedColumnsList, unnestExpressionsList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( tableNamePath != null, "tableNamePath must be set"); Preconditions.checkArgument( isUnique != null, "isUnique must be set"); Preconditions.checkArgument( indexItemList != null, "indexItemList must be set"); } } public static final ResolvedCreateIndexStmt deserialize( ResolvedCreateIndexStmtProto proto, AbstractDeserializationHelper 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()); // isSearch is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsSearch(this.getIsSearch()); // isVector is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsVector(this.getIsVector()); // indexAllColumns is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIndexAllColumns(this.getIndexAllColumns()); // 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()); } // 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()); } // 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 boolean getIsSearch() { return isSearch; } public final boolean getIsVector() { return isVector; } public final boolean getIndexAllColumns() { return indexAllColumns; } public final ImmutableList getIndexItemList() { return indexItemList; } public final ImmutableList getStoringExpressionList() { return storingExpressionList; } public final ImmutableList getPartitionByList() { return partitionByList; } 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 public ResolvedCreateIndexStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(indexItemList); visitor.descend(storingExpressionList); visitor.descend(partitionByList); visitor.descend(optionList); visitor.descend(computedColumnsList); visitor.descend(unnestExpressionsList); } public 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 (!DebugStrings.isDefaultValue(isSearch)) { fields.add(new DebugStringField("is_search", DebugStrings.toStringImpl(isSearch))); } if (!DebugStrings.isDefaultValue(isVector)) { fields.add(new DebugStringField("is_vector", DebugStrings.toStringImpl(isVector))); } if (!DebugStrings.isDefaultValue(indexAllColumns)) { fields.add(new DebugStringField("index_all_columns", DebugStrings.toStringImpl(indexAllColumns))); } if (!indexItemList.isEmpty()) { fields.add(new DebugStringField("index_item_list", indexItemList)); } if (!storingExpressionList.isEmpty()) { fields.add(new DebugStringField("storing_expression_list", storingExpressionList)); } if (!partitionByList.isEmpty()) { fields.add(new DebugStringField("partition_by_list", partitionByList)); } 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)); } } } /** * A base for statements that create schemas, such as: * CREATE [OR REPLACE] SCHEMA [IF NOT EXISTS] * [DEFAULT COLLATE ] * [OPTIONS (name=value, ...)] * * CREATE [OR REPLACE] [TEMP|TEMPORARY|PUBLIC|PRIVATE] EXTERNAL SCHEMA * [IF NOT EXISTS] [WITH CONNECTION] * OPTIONS (name=value, ...) * *

contains engine-specific options associated with the schema */ public static abstract class ResolvedCreateSchemaStmtBase extends ResolvedCreateStatement { private final ImmutableList optionList; ResolvedCreateSchemaStmtBase(ResolvedCreateSchemaStmtBaseProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedCreateSchemaStmtBase( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList) { super( hintList, namePath, createScope, createMode); this.optionList = optionList; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public abstract ResolvedCreateSchemaStmtBase build(); @Override protected void validate() { super.validate(); } } public static ResolvedCreateSchemaStmtBase deserialize( AnyResolvedCreateSchemaStmtBaseProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_CREATE_SCHEMA_STMT_NODE: return ResolvedCreateSchemaStmt.deserialize( proto.getResolvedCreateSchemaStmtNode(), helper); case RESOLVED_CREATE_EXTERNAL_SCHEMA_STMT_NODE: return ResolvedCreateExternalSchemaStmt.deserialize( proto.getResolvedCreateExternalSchemaStmtNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedCreateSchemaStmtBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedCreateSchemaStmtBaseProto.Builder builder = ResolvedCreateSchemaStmtBaseProto.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(); AnyResolvedCreateSchemaStmtBaseProto.Builder childBuilder = AnyResolvedCreateSchemaStmtBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateSchemaStmtBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedCreateSchemaStmtBaseProto.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, AnyResolvedCreateSchemaStmtBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedCreateSchemaStmtBaseProto.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, ResolvedCreateSchemaStmtBaseProto.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 abstract ResolvedCreateSchemaStmtBase accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This statement: * CREATE [OR REPLACE] SCHEMA [IF NOT EXISTS] * [DEFAULT COLLATE ] * [OPTIONS (name=value, ...)] * specifies the default collation specification for future * tables created in the dataset. If a table is created in this dataset * without specifying table-level default collation, it inherits the * dataset default collation. A change to this field affects only tables * created afterwards, not the existing tables. Only string literals * are allowed for this field. * * Note: If a table being created in this schema does not specify table * default collation, the engine should copy the dataset default collation * to the table as the table default collation. */ public static final class ResolvedCreateSchemaStmt extends ResolvedCreateSchemaStmtBase { private final ResolvedExpr collationName; ResolvedCreateSchemaStmt(ResolvedCreateSchemaStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasCollationName()) { collationName = ResolvedExpr.deserialize(proto.getCollationName(), helper); } else { collationName = null; } } ResolvedCreateSchemaStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ResolvedExpr collationName) { super( hintList, namePath, createScope, createMode, optionList); this.collationName = collationName; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); builder.collationName = this.getCollationName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateSchemaStmtBase.Builder { protected ResolvedExpr collationName = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setOptionList(List v) { super.setOptionList(v); return this; } @CanIgnoreReturnValue public Builder setCollationName(ResolvedExpr v) { this.collationName = v; return this; } @Override public final ResolvedCreateSchemaStmt build() { validate(); return new ResolvedCreateSchemaStmt( hintList, namePath, createScope, createMode, optionList, collationName); } @Override protected void validate() { super.validate(); } } public static final ResolvedCreateSchemaStmt deserialize( ResolvedCreateSchemaStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedCreateSchemaStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_SCHEMA_STMT; } @Override public final String nodeKindString() { return "CreateSchemaStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateSchemaStmtBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateSchemaStmtBaseProto.Builder builder = AnyResolvedCreateSchemaStmtBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateSchemaStmtBaseProto.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, AnyResolvedCreateSchemaStmtBaseProto.Builder builder) { builder.clear(); ResolvedCreateSchemaStmtProto.Builder childBuilder = ResolvedCreateSchemaStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateSchemaStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateSchemaStmtProto.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, ResolvedCreateSchemaStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateSchemaStmtBaseProto parent = (ResolvedCreateSchemaStmtBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // 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()); } } public final ResolvedExpr getCollationName() { return collationName; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateSchemaStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(collationName); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (collationName != null) { fields.add(new DebugStringField("collation_name", collationName)); } } } /** * This statement: * CREATE [OR REPLACE] [TEMP|TEMPORARY|PUBLIC|PRIVATE] EXTERNAL SCHEMA * [IF NOT EXISTS] [WITH CONNECTION] * OPTIONS (name=value, ...) * *

encapsulates engine-specific metadata used to connect * to an external data source * *

Note: external schemas are pointers to schemas defined in an external * system. CREATE EXTERNAL SCHEMA does not actually build a new schema. */ public static final class ResolvedCreateExternalSchemaStmt extends ResolvedCreateSchemaStmtBase { private final ResolvedConnection connection; ResolvedCreateExternalSchemaStmt(ResolvedCreateExternalSchemaStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } } ResolvedCreateExternalSchemaStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ResolvedConnection connection) { super( hintList, namePath, createScope, createMode, optionList); this.connection = connection; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); builder.connection = this.getConnection(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateSchemaStmtBase.Builder { protected ResolvedConnection connection = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setOptionList(List v) { super.setOptionList(v); return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @Override public final ResolvedCreateExternalSchemaStmt build() { validate(); return new ResolvedCreateExternalSchemaStmt( hintList, namePath, createScope, createMode, optionList, connection); } @Override protected void validate() { super.validate(); } } public static final ResolvedCreateExternalSchemaStmt deserialize( ResolvedCreateExternalSchemaStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedCreateExternalSchemaStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_EXTERNAL_SCHEMA_STMT; } @Override public final String nodeKindString() { return "CreateExternalSchemaStmt"; } /** * Serializes this node into a {@link AnyResolvedCreateSchemaStmtBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedCreateSchemaStmtBaseProto.Builder builder = AnyResolvedCreateSchemaStmtBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedCreateSchemaStmtBaseProto.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, AnyResolvedCreateSchemaStmtBaseProto.Builder builder) { builder.clear(); ResolvedCreateExternalSchemaStmtProto.Builder childBuilder = ResolvedCreateExternalSchemaStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateExternalSchemaStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateExternalSchemaStmtProto.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, ResolvedCreateExternalSchemaStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateSchemaStmtBaseProto parent = (ResolvedCreateSchemaStmtBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.build()); } } public final ResolvedConnection getConnection() { return connection; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateExternalSchemaStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(connection); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (connection != null) { fields.add(new DebugStringField("connection", connection)); } } } /** * This statement: * CREATE [TEMP] TABLE [(column type, ...) | LIKE ] * [DEFAULT COLLATE ] [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 ABSL_CHECK constraints on the table. * specifies the partitioning expressions for the table. * specifies the clustering expressions for the table. * TODO: Return error when the PARTITION BY / CLUSTER BY * expression resolves to have collation specified. * specifies whether the table is a value table. * See (broken link). * identifies the table in the LIKE . * By default, all fields (column names, types, constraints, * keys, clustering etc.) will be inherited from the source * table. But if explicitly set, the explicit settings will * take precedence. * specifies the default collation specification to apply to * newly added STRING fields in this table. A change of this field affects * only the STRING columns and the STRING fields in STRUCTs added * afterwards, not existing columns. Only string literals are allowed for * this field. * * Note: During table creation or alteration, if a STRING field is added to * this table without explicit collation specified, the engine should copy * the table default collation to the STRING field. */ 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 boolean isValueTable; private final Table likeTable; private final ResolvedExpr collationName; private final ResolvedConnection connection; ResolvedCreateTableStmtBase(ResolvedCreateTableStmtBaseProto proto, AbstractDeserializationHelper 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(); isValueTable = proto.getIsValueTable(); likeTable = helper.deserialize(proto.getLikeTable()); if (proto.hasCollationName()) { collationName = ResolvedExpr.deserialize(proto.getCollationName(), helper); } else { collationName = null; } if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } } ResolvedCreateTableStmtBase( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ImmutableList columnDefinitionList, ImmutableList pseudoColumnList, ResolvedPrimaryKey primaryKey, ImmutableList foreignKeyList, ImmutableList checkConstraintList, boolean isValueTable, Table likeTable, ResolvedExpr collationName, ResolvedConnection connection) { super( hintList, namePath, createScope, createMode); this.optionList = optionList; this.columnDefinitionList = columnDefinitionList; this.pseudoColumnList = pseudoColumnList; this.primaryKey = primaryKey; this.foreignKeyList = foreignKeyList; this.checkConstraintList = checkConstraintList; this.isValueTable = isValueTable; this.likeTable = likeTable; this.collationName = collationName; this.connection = connection; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList optionList = null; protected ImmutableList columnDefinitionList = null; protected ImmutableList pseudoColumnList = null; protected ResolvedPrimaryKey primaryKey = null; protected ImmutableList foreignKeyList = null; protected ImmutableList checkConstraintList = null; protected Boolean isValueTable = null; protected Table likeTable = null; protected ResolvedExpr collationName = null; protected ResolvedConnection connection = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { this.columnDefinitionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setPseudoColumnList(List v) { this.pseudoColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setPrimaryKey(ResolvedPrimaryKey v) { this.primaryKey = v; return this; } @CanIgnoreReturnValue public Builder setForeignKeyList(List v) { this.foreignKeyList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setCheckConstraintList(List v) { this.checkConstraintList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { this.isValueTable = v; return this; } @CanIgnoreReturnValue public Builder setLikeTable(Table v) { this.likeTable = v; return this; } @CanIgnoreReturnValue public Builder setCollationName(ResolvedExpr v) { this.collationName = v; return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @Override public abstract ResolvedCreateTableStmtBase build(); @Override protected void validate() { super.validate(); } } public static ResolvedCreateTableStmtBase deserialize( AnyResolvedCreateTableStmtBaseProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_CREATE_TABLE_AS_SELECT_STMT_NODE: return ResolvedCreateTableAsSelectStmt.deserialize( proto.getResolvedCreateTableAsSelectStmtNode(), helper); case RESOLVED_CREATE_EXTERNAL_TABLE_STMT_NODE: return ResolvedCreateExternalTableStmt.deserialize( proto.getResolvedCreateExternalTableStmtNode(), 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()); } // 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()); // likeTable is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getLikeTable() != null) { proto.setLikeTable( ResolvedNodes.serialize(this.getLikeTable(), fileDescriptorSetsBuilder)); } // 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()); } // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.build()); } } 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 boolean getIsValueTable() { return isValueTable; } public final Table getLikeTable() { return likeTable; } public final ResolvedExpr getCollationName() { return collationName; } public final ResolvedConnection getConnection() { return connection; } @Override public abstract ResolvedCreateTableStmtBase accept(RewritingVisitor visitor); @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(collationName); visitor.descend(connection); } public 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 (!DebugStrings.isDefaultValue(isValueTable)) { fields.add(new DebugStringField("is_value_table", DebugStrings.toStringImpl(isValueTable))); } if (!DebugStrings.isDefaultValue(likeTable)) { fields.add(new DebugStringField("like_table", DebugStrings.toStringImpl(likeTable))); } if (collationName != null) { fields.add(new DebugStringField("collation_name", collationName)); } if (connection != null) { fields.add(new DebugStringField("connection", connection)); } } } /** * This statement: * CREATE [TEMP] TABLE * [(column schema, ...) | LIKE | * {CLONE|COPY} * [FOR SYSTEM_TIME AS OF ] * [WHERE ]] * [DEFAULT COLLATE ] * [PARTITION BY expr, ...] [CLUSTER BY expr, ...] * [WITH CONNECTION connection_name] * [OPTIONS (...)] * *

One of or can be present for CLONE or COPY. * specifies the data source to clone from (cheap, typically * O(1) operation); while is intended for a full copy. * * ResolvedTableScan will represent the source table, with an optional * for_system_time_expr. * * The ResolvedTableScan may be wrapped inside a ResolvedFilterScan if the * source table has a where clause. No other Scan types are allowed here. * * If the OPTIONS clause is explicitly specified, the option values are * intended to be used for the created or replaced table. * If any OPTION is unspecified, the corresponding option from the source * table will be used instead. * * The 'clone_from.column_list' field may be set, but should be ignored. * * clone_from and copy_from cannot be value tables. */ public static final class ResolvedCreateTableStmt extends ResolvedCreateTableStmtBase { private final ResolvedScan cloneFrom; private final ResolvedScan copyFrom; private final ImmutableList partitionByList; private final ImmutableList clusterByList; ResolvedCreateTableStmt(ResolvedCreateTableStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasCloneFrom()) { cloneFrom = ResolvedScan.deserialize(proto.getCloneFrom(), helper); } else { cloneFrom = null; } if (proto.hasCopyFrom()) { copyFrom = ResolvedScan.deserialize(proto.getCopyFrom(), helper); } else { copyFrom = null; } 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(); } ResolvedCreateTableStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ImmutableList columnDefinitionList, ImmutableList pseudoColumnList, ResolvedPrimaryKey primaryKey, ImmutableList foreignKeyList, ImmutableList checkConstraintList, boolean isValueTable, Table likeTable, ResolvedExpr collationName, ResolvedConnection connection, ResolvedScan cloneFrom, ResolvedScan copyFrom, ImmutableList partitionByList, ImmutableList clusterByList) { super( hintList, namePath, createScope, createMode, optionList, columnDefinitionList, pseudoColumnList, primaryKey, foreignKeyList, checkConstraintList, isValueTable, likeTable, collationName, connection); this.cloneFrom = cloneFrom; this.copyFrom = copyFrom; this.partitionByList = partitionByList; this.clusterByList = clusterByList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); builder.columnDefinitionList = this.getColumnDefinitionList(); builder.pseudoColumnList = this.getPseudoColumnList(); builder.primaryKey = this.getPrimaryKey(); builder.foreignKeyList = this.getForeignKeyList(); builder.checkConstraintList = this.getCheckConstraintList(); builder.isValueTable = this.getIsValueTable(); builder.likeTable = this.getLikeTable(); builder.collationName = this.getCollationName(); builder.connection = this.getConnection(); builder.cloneFrom = this.getCloneFrom(); builder.copyFrom = this.getCopyFrom(); builder.partitionByList = this.getPartitionByList(); builder.clusterByList = this.getClusterByList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateTableStmtBase.Builder { protected ResolvedScan cloneFrom = null; protected ResolvedScan copyFrom = null; protected ImmutableList partitionByList = null; protected ImmutableList clusterByList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setOptionList(List v) { super.setOptionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { super.setColumnDefinitionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setPseudoColumnList(List v) { super.setPseudoColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setPrimaryKey(ResolvedPrimaryKey v) { super.setPrimaryKey(v); return this; } @Override @CanIgnoreReturnValue public Builder setForeignKeyList(List v) { super.setForeignKeyList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCheckConstraintList(List v) { super.setCheckConstraintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { super.setIsValueTable(v); return this; } @Override @CanIgnoreReturnValue public Builder setLikeTable(Table v) { super.setLikeTable(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationName(ResolvedExpr v) { super.setCollationName(v); return this; } @Override @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { super.setConnection(v); return this; } @CanIgnoreReturnValue public Builder setCloneFrom(ResolvedScan v) { this.cloneFrom = v; return this; } @CanIgnoreReturnValue public Builder setCopyFrom(ResolvedScan v) { this.copyFrom = v; return this; } @CanIgnoreReturnValue public Builder setPartitionByList(List v) { this.partitionByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setClusterByList(List v) { this.clusterByList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCreateTableStmt build() { validate(); return new ResolvedCreateTableStmt( hintList, namePath, createScope, createMode, optionList, columnDefinitionList, pseudoColumnList, primaryKey, foreignKeyList, checkConstraintList, isValueTable, likeTable, collationName, connection, cloneFrom, copyFrom, partitionByList, clusterByList); } @Override protected void validate() { super.validate(); } } public static final ResolvedCreateTableStmt deserialize( ResolvedCreateTableStmtProto proto, AbstractDeserializationHelper 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); // cloneFrom is an AST node. Call its serialization chain. if (this.getCloneFrom() != null) { AnyResolvedScanProto.Builder cloneFromBuilder = AnyResolvedScanProto.newBuilder(); this.getCloneFrom().serialize( fileDescriptorSetsBuilder, cloneFromBuilder); proto.setCloneFrom( cloneFromBuilder.build()); } // copyFrom is an AST node. Call its serialization chain. if (this.getCopyFrom() != null) { AnyResolvedScanProto.Builder copyFromBuilder = AnyResolvedScanProto.newBuilder(); this.getCopyFrom().serialize( fileDescriptorSetsBuilder, copyFromBuilder); proto.setCopyFrom( copyFromBuilder.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 ResolvedScan getCloneFrom() { return cloneFrom; } public final ResolvedScan getCopyFrom() { return copyFrom; } public final ImmutableList getPartitionByList() { return partitionByList; } public final ImmutableList getClusterByList() { return clusterByList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateTableStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(cloneFrom); visitor.descend(copyFrom); visitor.descend(partitionByList); visitor.descend(clusterByList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (cloneFrom != null) { fields.add(new DebugStringField("clone_from", cloneFrom)); } if (copyFrom != null) { fields.add(new DebugStringField("copy_from", copyFrom)); } if (!partitionByList.isEmpty()) { fields.add(new DebugStringField("partition_by_list", partitionByList)); } if (!clusterByList.isEmpty()) { fields.add(new DebugStringField("cluster_by_list", clusterByList)); } } } /** * This statement: * CREATE [TEMP] TABLE [(column schema, ...) | LIKE ] * [DEFAULT COLLATE ] [PARTITION BY expr, ...] * [CLUSTER BY expr, ...] * [WITH CONNECTION connection_name] * [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 partitionByList; private final ImmutableList clusterByList; private final ImmutableList outputColumnList; private final ResolvedScan query; ResolvedCreateTableAsSelectStmt(ResolvedCreateTableAsSelectStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); 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(); 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; } } ResolvedCreateTableAsSelectStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ImmutableList columnDefinitionList, ImmutableList pseudoColumnList, ResolvedPrimaryKey primaryKey, ImmutableList foreignKeyList, ImmutableList checkConstraintList, boolean isValueTable, Table likeTable, ResolvedExpr collationName, ResolvedConnection connection, ImmutableList partitionByList, ImmutableList clusterByList, ImmutableList outputColumnList, ResolvedScan query) { super( hintList, namePath, createScope, createMode, optionList, columnDefinitionList, pseudoColumnList, primaryKey, foreignKeyList, checkConstraintList, isValueTable, likeTable, collationName, connection); this.partitionByList = partitionByList; this.clusterByList = clusterByList; this.outputColumnList = outputColumnList; this.query = query; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); builder.columnDefinitionList = this.getColumnDefinitionList(); builder.pseudoColumnList = this.getPseudoColumnList(); builder.primaryKey = this.getPrimaryKey(); builder.foreignKeyList = this.getForeignKeyList(); builder.checkConstraintList = this.getCheckConstraintList(); builder.isValueTable = this.getIsValueTable(); builder.likeTable = this.getLikeTable(); builder.collationName = this.getCollationName(); builder.connection = this.getConnection(); builder.partitionByList = this.getPartitionByList(); builder.clusterByList = this.getClusterByList(); builder.outputColumnList = this.getOutputColumnList(); builder.query = this.getQuery(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateTableStmtBase.Builder { protected ImmutableList partitionByList = null; protected ImmutableList clusterByList = null; protected ImmutableList outputColumnList = null; protected ResolvedScan query = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setOptionList(List v) { super.setOptionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { super.setColumnDefinitionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setPseudoColumnList(List v) { super.setPseudoColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setPrimaryKey(ResolvedPrimaryKey v) { super.setPrimaryKey(v); return this; } @Override @CanIgnoreReturnValue public Builder setForeignKeyList(List v) { super.setForeignKeyList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCheckConstraintList(List v) { super.setCheckConstraintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { super.setIsValueTable(v); return this; } @Override @CanIgnoreReturnValue public Builder setLikeTable(Table v) { super.setLikeTable(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationName(ResolvedExpr v) { super.setCollationName(v); return this; } @Override @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { super.setConnection(v); return this; } @CanIgnoreReturnValue public Builder setPartitionByList(List v) { this.partitionByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setClusterByList(List v) { this.clusterByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; Preconditions.checkNotNull(v, "query must not be null"); return this; } @Override public final ResolvedCreateTableAsSelectStmt build() { validate(); return new ResolvedCreateTableAsSelectStmt( hintList, namePath, createScope, createMode, optionList, columnDefinitionList, pseudoColumnList, primaryKey, foreignKeyList, checkConstraintList, isValueTable, likeTable, collationName, connection, partitionByList, clusterByList, outputColumnList, query); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( outputColumnList != null, "outputColumnList must be set"); Preconditions.checkArgument( query != null, "query must be set"); } } public static final ResolvedCreateTableAsSelectStmt deserialize( ResolvedCreateTableAsSelectStmtProto proto, AbstractDeserializationHelper 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); // 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()); } // 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 getPartitionByList() { return partitionByList; } public final ImmutableList getClusterByList() { return clusterByList; } public final ImmutableList getOutputColumnList() { return outputColumnList; } public final ResolvedScan getQuery() { return query; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateTableAsSelectStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(partitionByList); visitor.descend(clusterByList); visitor.descend(outputColumnList); visitor.descend(query); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!partitionByList.isEmpty()) { fields.add(new DebugStringField("partition_by_list", partitionByList)); } if (!clusterByList.isEmpty()) { fields.add(new DebugStringField("cluster_by_list", clusterByList)); } if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } if (query != null) { fields.add(new DebugStringField("query", query)); } } } /** * Resolves a create model aliased query: * identifier AS * *

is the string representation of identifier. * is the ResolvedScan of the subquery. * matches 1:1 with the 's column_list and * identifies the names and types of the columns output from the query. */ public static final class ResolvedCreateModelAliasedQuery extends ResolvedArgument { private final String alias; private final ResolvedScan query; private final ImmutableList outputColumnList; ResolvedCreateModelAliasedQuery(ResolvedCreateModelAliasedQueryProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); alias = proto.getAlias(); 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(); } ResolvedCreateModelAliasedQuery( String alias, ResolvedScan query, ImmutableList outputColumnList) { super(); this.alias = alias; this.query = query; this.outputColumnList = outputColumnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.alias = this.getAlias(); builder.query = this.getQuery(); builder.outputColumnList = this.getOutputColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String alias = null; protected ResolvedScan query = null; protected ImmutableList outputColumnList = null; private Builder() {} @CanIgnoreReturnValue public Builder setAlias(String v) { this.alias = v; Preconditions.checkNotNull(v, "alias must not be null"); return this; } @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; Preconditions.checkNotNull(v, "query must not be null"); return this; } @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCreateModelAliasedQuery build() { validate(); return new ResolvedCreateModelAliasedQuery( alias, query, outputColumnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( alias != null, "alias must be set"); Preconditions.checkArgument( query != null, "query must be set"); Preconditions.checkArgument( outputColumnList != null, "outputColumnList must be set"); } } public static final ResolvedCreateModelAliasedQuery deserialize( ResolvedCreateModelAliasedQueryProto proto, AbstractDeserializationHelper helper) { return new ResolvedCreateModelAliasedQuery(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_MODEL_ALIASED_QUERY; } @Override public final String nodeKindString() { return "CreateModelAliasedQuery"; } /** * 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(); ResolvedCreateModelAliasedQueryProto.Builder childBuilder = ResolvedCreateModelAliasedQueryProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateModelAliasedQueryNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateModelAliasedQueryProto.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, ResolvedCreateModelAliasedQueryProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // 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()); // 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()); } } public final String getAlias() { return alias; } public final ResolvedScan getQuery() { return query; } public final ImmutableList getOutputColumnList() { return outputColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateModelAliasedQuery accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(query); visitor.descend(outputColumnList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("alias", DebugStrings.toStringImpl(alias))); } if (query != null) { fields.add(new DebugStringField("query", query)); } if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } } } /** * This statement: * CREATE [TEMP] MODEL [INPUT(...) OUTPUT(...)] [TRANSFORM(...)] * [REMOTE [WITH CONNECTION ...]] [OPTIONS (...)] * [AS | ( AS () [, ...])] * *

At most one of and can be set. is * used when there is a single query as input. is used * for the syntax with multiple queries with identifiers. For below, let * be true if either of these are present. * *

Models can be evaluated either locally or remotely. Orthogonally, they can * be either trained using SQL or come from external source. Depending on * these properties, different clauses are expected to be present. * *

* Local models = FALSE * * Trained: * * External: ! * * Remote models = TRUE * * Trained: * * External: ! * *

has engine-specific directives for how to train this model. * is the AS SELECT statement. It can be only set when all of * , and * are empty. * TODO: consider rename to . * matches 1:1 with the 's column_list and * identifies the names and types of the columns output from the select * statement. Set only when is present. * contains names and types of model's input * columns. Cannot be set if is true. Might be absent when * is true, meaning schema is read from the remote model * itself. * contains names and types of model's output * columns. Cannot be set if is true. Might be absent when * is true, meaning schema is read from the remote model * itself. * is true if this is a remote model. * is the identifier path of the connection object. It can be * only set when is true. * is the list of ResolvedComputedColumn in TRANSFORM * clause. It can be only set when is present. * 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. * 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) * is the aliased query list. It can only be set when * is false and is null. It cannot coexist with any * transform related resolved nodes. */ public static final class ResolvedCreateModelStmt extends ResolvedCreateStatement { private final ImmutableList optionList; private final ImmutableList outputColumnList; private final ResolvedScan query; private final ImmutableList aliasedQueryList; private final ImmutableList transformInputColumnList; private final ImmutableList transformList; private final ImmutableList transformOutputColumnList; private final ImmutableList transformAnalyticFunctionGroupList; private final ImmutableList inputColumnDefinitionList; private final ImmutableList outputColumnDefinitionList; private final boolean isRemote; private final ResolvedConnection connection; ResolvedCreateModelStmt(ResolvedCreateModelStmtProto proto, AbstractDeserializationHelper 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 aliasedQueryListBuilder = ImmutableList.builder(); for (ResolvedCreateModelAliasedQueryProto element : proto.getAliasedQueryListList()) { aliasedQueryListBuilder .add(ResolvedCreateModelAliasedQuery.deserialize(element, helper)); } aliasedQueryList = aliasedQueryListBuilder.build(); 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(); ImmutableList.Builder inputColumnDefinitionListBuilder = ImmutableList.builder(); for (ResolvedColumnDefinitionProto element : proto.getInputColumnDefinitionListList()) { inputColumnDefinitionListBuilder .add(ResolvedColumnDefinition.deserialize(element, helper)); } inputColumnDefinitionList = inputColumnDefinitionListBuilder.build(); ImmutableList.Builder outputColumnDefinitionListBuilder = ImmutableList.builder(); for (ResolvedColumnDefinitionProto element : proto.getOutputColumnDefinitionListList()) { outputColumnDefinitionListBuilder .add(ResolvedColumnDefinition.deserialize(element, helper)); } outputColumnDefinitionList = outputColumnDefinitionListBuilder.build(); isRemote = proto.getIsRemote(); if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } } ResolvedCreateModelStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ImmutableList outputColumnList, ResolvedScan query, ImmutableList aliasedQueryList, ImmutableList transformInputColumnList, ImmutableList transformList, ImmutableList transformOutputColumnList, ImmutableList transformAnalyticFunctionGroupList, ImmutableList inputColumnDefinitionList, ImmutableList outputColumnDefinitionList, boolean isRemote, ResolvedConnection connection) { super( hintList, namePath, createScope, createMode); this.optionList = optionList; this.outputColumnList = outputColumnList; this.query = query; this.aliasedQueryList = aliasedQueryList; this.transformInputColumnList = transformInputColumnList; this.transformList = transformList; this.transformOutputColumnList = transformOutputColumnList; this.transformAnalyticFunctionGroupList = transformAnalyticFunctionGroupList; this.inputColumnDefinitionList = inputColumnDefinitionList; this.outputColumnDefinitionList = outputColumnDefinitionList; this.isRemote = isRemote; this.connection = connection; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); builder.outputColumnList = this.getOutputColumnList(); builder.query = this.getQuery(); builder.aliasedQueryList = this.getAliasedQueryList(); builder.transformInputColumnList = this.getTransformInputColumnList(); builder.transformList = this.getTransformList(); builder.transformOutputColumnList = this.getTransformOutputColumnList(); builder.transformAnalyticFunctionGroupList = this.getTransformAnalyticFunctionGroupList(); builder.inputColumnDefinitionList = this.getInputColumnDefinitionList(); builder.outputColumnDefinitionList = this.getOutputColumnDefinitionList(); builder.isRemote = this.getIsRemote(); builder.connection = this.getConnection(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList optionList = null; protected ImmutableList outputColumnList = null; protected ResolvedScan query = null; protected ImmutableList aliasedQueryList = null; protected ImmutableList transformInputColumnList = null; protected ImmutableList transformList = null; protected ImmutableList transformOutputColumnList = null; protected ImmutableList transformAnalyticFunctionGroupList = null; protected ImmutableList inputColumnDefinitionList = null; protected ImmutableList outputColumnDefinitionList = null; protected Boolean isRemote = null; protected ResolvedConnection connection = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; Preconditions.checkNotNull(v, "query must not be null"); return this; } @CanIgnoreReturnValue public Builder setAliasedQueryList(List v) { this.aliasedQueryList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setTransformInputColumnList(List v) { this.transformInputColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setTransformList(List v) { this.transformList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setTransformOutputColumnList(List v) { this.transformOutputColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setTransformAnalyticFunctionGroupList(List v) { this.transformAnalyticFunctionGroupList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setInputColumnDefinitionList(List v) { this.inputColumnDefinitionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOutputColumnDefinitionList(List v) { this.outputColumnDefinitionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIsRemote(boolean v) { this.isRemote = v; return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @Override public final ResolvedCreateModelStmt build() { validate(); return new ResolvedCreateModelStmt( hintList, namePath, createScope, createMode, optionList, outputColumnList, query, aliasedQueryList, transformInputColumnList, transformList, transformOutputColumnList, transformAnalyticFunctionGroupList, inputColumnDefinitionList, outputColumnDefinitionList, isRemote, connection); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( query != null, "query must be set"); } } public static final ResolvedCreateModelStmt deserialize( ResolvedCreateModelStmtProto proto, AbstractDeserializationHelper 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()); } // aliasedQueryList is a collection of AST nodes. Serialize each of them. ImmutableList aliasedQueryLists = this.getAliasedQueryList(); for (ResolvedCreateModelAliasedQuery element : aliasedQueryLists) { ResolvedCreateModelAliasedQueryProto.Builder aliasedQueryListBuilder = ResolvedCreateModelAliasedQueryProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, aliasedQueryListBuilder); proto.addAliasedQueryList(aliasedQueryListBuilder.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()); } // inputColumnDefinitionList is a collection of AST nodes. Serialize each of them. ImmutableList inputColumnDefinitionLists = this.getInputColumnDefinitionList(); for (ResolvedColumnDefinition element : inputColumnDefinitionLists) { ResolvedColumnDefinitionProto.Builder inputColumnDefinitionListBuilder = ResolvedColumnDefinitionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, inputColumnDefinitionListBuilder); proto.addInputColumnDefinitionList(inputColumnDefinitionListBuilder.build()); } // outputColumnDefinitionList is a collection of AST nodes. Serialize each of them. ImmutableList outputColumnDefinitionLists = this.getOutputColumnDefinitionList(); for (ResolvedColumnDefinition element : outputColumnDefinitionLists) { ResolvedColumnDefinitionProto.Builder outputColumnDefinitionListBuilder = ResolvedColumnDefinitionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, outputColumnDefinitionListBuilder); proto.addOutputColumnDefinitionList(outputColumnDefinitionListBuilder.build()); } // isRemote is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsRemote(this.getIsRemote()); // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.build()); } } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getOutputColumnList() { return outputColumnList; } public final ResolvedScan getQuery() { return query; } public final ImmutableList getAliasedQueryList() { return aliasedQueryList; } public final ImmutableList getTransformInputColumnList() { return transformInputColumnList; } public final ImmutableList getTransformList() { return transformList; } public final ImmutableList getTransformOutputColumnList() { return transformOutputColumnList; } public final ImmutableList getTransformAnalyticFunctionGroupList() { return transformAnalyticFunctionGroupList; } public final ImmutableList getInputColumnDefinitionList() { return inputColumnDefinitionList; } public final ImmutableList getOutputColumnDefinitionList() { return outputColumnDefinitionList; } public final boolean getIsRemote() { return isRemote; } public final ResolvedConnection getConnection() { return connection; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateModelStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(outputColumnList); visitor.descend(query); visitor.descend(aliasedQueryList); visitor.descend(transformInputColumnList); visitor.descend(transformList); visitor.descend(transformOutputColumnList); visitor.descend(transformAnalyticFunctionGroupList); visitor.descend(inputColumnDefinitionList); visitor.descend(outputColumnDefinitionList); visitor.descend(connection); } public 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 (!aliasedQueryList.isEmpty()) { fields.add(new DebugStringField("aliased_query_list", aliasedQueryList)); } 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)); } if (!inputColumnDefinitionList.isEmpty()) { fields.add(new DebugStringField("input_column_definition_list", inputColumnDefinitionList)); } if (!outputColumnDefinitionList.isEmpty()) { fields.add(new DebugStringField("output_column_definition_list", outputColumnDefinitionList)); } if (!DebugStrings.isDefaultValue(isRemote)) { fields.add(new DebugStringField("is_remote", DebugStrings.toStringImpl(isRemote))); } if (connection != null) { fields.add(new DebugStringField("connection", connection)); } } } /** * Common superclass for CREATE view/materialized view: * CREATE [TEMP|MATERIALIZED] [RECURSIVE] 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. If is * true, names will be explicitly provided. * If this is set, the statement includes an explicit * column name list. These column names should still be applied even if the * query changes or is re-resolved in the future. The view becomes invalid * if the query produces a different number of columns. * is the query to run. * is the view query text. * is the declared security mode for the function. Values * include 'INVOKER', 'DEFINER'. * specifies whether or not the view is created with the * RECURSIVE keyword. * matches 1:1 with the and * provides explicit definition for each output column. 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 also contains the * column OPTIONS. Therefore, consumers are encouraged to read from * rather than from to * determine the schema, if possible. * *

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 boolean hasExplicitColumns; 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; /** * True if the view uses the RECURSIVE keyword. * can be a ResolvedRecursiveScan only if this is true. */ private final boolean recursive; private final ImmutableList columnDefinitionList; ResolvedCreateViewBase(ResolvedCreateViewBaseProto proto, AbstractDeserializationHelper 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(); hasExplicitColumns = proto.getHasExplicitColumns(); if (proto.hasQuery()) { query = ResolvedScan.deserialize(proto.getQuery(), helper); } else { query = null; } sql = proto.getSql(); sqlSecurity = proto.getSqlSecurity(); isValueTable = proto.getIsValueTable(); recursive = proto.getRecursive(); ImmutableList.Builder columnDefinitionListBuilder = ImmutableList.builder(); for (ResolvedColumnDefinitionProto element : proto.getColumnDefinitionListList()) { columnDefinitionListBuilder .add(ResolvedColumnDefinition.deserialize(element, helper)); } columnDefinitionList = columnDefinitionListBuilder.build(); } ResolvedCreateViewBase( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ImmutableList outputColumnList, boolean hasExplicitColumns, ResolvedScan query, String sql, SqlSecurity sqlSecurity, boolean isValueTable, boolean recursive, ImmutableList columnDefinitionList) { super( hintList, namePath, createScope, createMode); this.optionList = optionList; this.outputColumnList = outputColumnList; this.hasExplicitColumns = hasExplicitColumns; this.query = query; this.sql = sql; this.sqlSecurity = sqlSecurity; this.isValueTable = isValueTable; this.recursive = recursive; this.columnDefinitionList = columnDefinitionList; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList optionList = null; protected ImmutableList outputColumnList = null; protected Boolean hasExplicitColumns = null; protected ResolvedScan query = null; protected String sql = null; protected SqlSecurity sqlSecurity = null; protected Boolean isValueTable = null; protected Boolean recursive = null; protected ImmutableList columnDefinitionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setHasExplicitColumns(boolean v) { this.hasExplicitColumns = v; return this; } @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; return this; } @CanIgnoreReturnValue public Builder setSql(String v) { this.sql = v; return this; } @CanIgnoreReturnValue public Builder setSqlSecurity(SqlSecurity v) { this.sqlSecurity = v; return this; } /** * 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). */ @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { this.isValueTable = v; return this; } /** * True if the view uses the RECURSIVE keyword. * can be a ResolvedRecursiveScan only if this is true. */ @CanIgnoreReturnValue public Builder setRecursive(boolean v) { this.recursive = v; return this; } @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { this.columnDefinitionList = ImmutableList.copyOf(v); return this; } @Override public abstract ResolvedCreateViewBase build(); @Override protected void validate() { super.validate(); Preconditions.checkArgument( outputColumnList != null, "outputColumnList must be set"); } } public static ResolvedCreateViewBase deserialize( AnyResolvedCreateViewBaseProto proto, AbstractDeserializationHelper 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); case RESOLVED_CREATE_APPROX_VIEW_STMT_NODE: return ResolvedCreateApproxViewStmt.deserialize( proto.getResolvedCreateApproxViewStmtNode(), 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()); } // hasExplicitColumns is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setHasExplicitColumns(this.getHasExplicitColumns()); // 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()); // recursive is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setRecursive(this.getRecursive()); // 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()); } } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getOutputColumnList() { return outputColumnList; } public final boolean getHasExplicitColumns() { return hasExplicitColumns; } 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; } /** * True if the view uses the RECURSIVE keyword. * can be a ResolvedRecursiveScan only if this is true. */ public final boolean getRecursive() { return recursive; } public final ImmutableList getColumnDefinitionList() { return columnDefinitionList; } @Override public abstract ResolvedCreateViewBase accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(outputColumnList); visitor.descend(query); visitor.descend(columnDefinitionList); } public 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(hasExplicitColumns)) { fields.add(new DebugStringField("has_explicit_columns", DebugStrings.toStringImpl(hasExplicitColumns))); } 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))); } if (!DebugStrings.isDefaultValue(recursive)) { fields.add(new DebugStringField("recursive", DebugStrings.toStringImpl(recursive))); } if (!columnDefinitionList.isEmpty()) { fields.add(new DebugStringField("column_definition_list", columnDefinitionList)); } } } /** * This statement: * CREATE [TEMP] VIEW [(...)] [OPTIONS (...)] AS SELECT ... */ public static final class ResolvedCreateViewStmt extends ResolvedCreateViewBase { ResolvedCreateViewStmt(ResolvedCreateViewStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedCreateViewStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ImmutableList outputColumnList, boolean hasExplicitColumns, ResolvedScan query, String sql, SqlSecurity sqlSecurity, boolean isValueTable, boolean recursive, ImmutableList columnDefinitionList) { super( hintList, namePath, createScope, createMode, optionList, outputColumnList, hasExplicitColumns, query, sql, sqlSecurity, isValueTable, recursive, columnDefinitionList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); builder.outputColumnList = this.getOutputColumnList(); builder.hasExplicitColumns = this.getHasExplicitColumns(); builder.query = this.getQuery(); builder.sql = this.getSql(); builder.sqlSecurity = this.getSqlSecurity(); builder.isValueTable = this.getIsValueTable(); builder.recursive = this.getRecursive(); builder.columnDefinitionList = this.getColumnDefinitionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateViewBase.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setOptionList(List v) { super.setOptionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { super.setOutputColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHasExplicitColumns(boolean v) { super.setHasExplicitColumns(v); return this; } @Override @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { super.setQuery(v); return this; } @Override @CanIgnoreReturnValue public Builder setSql(String v) { super.setSql(v); return this; } @Override @CanIgnoreReturnValue public Builder setSqlSecurity(SqlSecurity v) { super.setSqlSecurity(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { super.setIsValueTable(v); return this; } @Override @CanIgnoreReturnValue public Builder setRecursive(boolean v) { super.setRecursive(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { super.setColumnDefinitionList(v); return this; } @Override public final ResolvedCreateViewStmt build() { validate(); return new ResolvedCreateViewStmt( hintList, namePath, createScope, createMode, optionList, outputColumnList, hasExplicitColumns, query, sql, sqlSecurity, isValueTable, recursive, columnDefinitionList); } @Override protected void validate() { super.validate(); } } public static final ResolvedCreateViewStmt deserialize( ResolvedCreateViewStmtProto proto, AbstractDeserializationHelper 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 public ResolvedCreateViewStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: * WITH PARTITION COLUMNS [(column schema, ...)] */ public static final class ResolvedWithPartitionColumns extends ResolvedArgument { private final ImmutableList columnDefinitionList; ResolvedWithPartitionColumns(ResolvedWithPartitionColumnsProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder columnDefinitionListBuilder = ImmutableList.builder(); for (ResolvedColumnDefinitionProto element : proto.getColumnDefinitionListList()) { columnDefinitionListBuilder .add(ResolvedColumnDefinition.deserialize(element, helper)); } columnDefinitionList = columnDefinitionListBuilder.build(); } ResolvedWithPartitionColumns( ImmutableList columnDefinitionList) { super(); this.columnDefinitionList = columnDefinitionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnDefinitionList = this.getColumnDefinitionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList columnDefinitionList = null; private Builder() {} @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { this.columnDefinitionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedWithPartitionColumns build() { validate(); return new ResolvedWithPartitionColumns( columnDefinitionList); } @Override protected void validate() { super.validate(); } } public static final ResolvedWithPartitionColumns deserialize( ResolvedWithPartitionColumnsProto proto, AbstractDeserializationHelper helper) { return new ResolvedWithPartitionColumns(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_WITH_PARTITION_COLUMNS; } @Override public final String nodeKindString() { return "WithPartitionColumns"; } /** * 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(); ResolvedWithPartitionColumnsProto.Builder childBuilder = ResolvedWithPartitionColumnsProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedWithPartitionColumnsNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedWithPartitionColumnsProto.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, ResolvedWithPartitionColumnsProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) 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()); } } public final ImmutableList getColumnDefinitionList() { return columnDefinitionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedWithPartitionColumns accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnDefinitionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!columnDefinitionList.isEmpty()) { fields.add(new DebugStringField("column_definition_list", columnDefinitionList)); } } } /** * This statement: * CREATE SNAPSHOT TABLE [IF NOT EXISTS] [OPTIONS (...)] * CLONE * [FOR SYSTEM_TIME AS OF ] * *

the source data to clone data from. * ResolvedTableScan will represent the source table, with an * optional for_system_time_expr. * The ResolvedTableScan may be wrapped inside a * ResolvedFilterScan if the source table has a where clause. * No other Scan types are allowed here. * By default, all fields (column names, types, constraints, * partition, clustering, options etc.) will be inherited from * the source table. If table options are explicitly set, the * explicit options will take precedence. * The 'clone_from.column_list' field may be set, but should be * ignored. */ public static final class ResolvedCreateSnapshotTableStmt extends ResolvedCreateStatement { private final ResolvedScan cloneFrom; private final ImmutableList optionList; ResolvedCreateSnapshotTableStmt(ResolvedCreateSnapshotTableStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasCloneFrom()) { cloneFrom = ResolvedScan.deserialize(proto.getCloneFrom(), helper); } else { cloneFrom = null; } ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedCreateSnapshotTableStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ResolvedScan cloneFrom, ImmutableList optionList) { super( hintList, namePath, createScope, createMode); this.cloneFrom = cloneFrom; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.cloneFrom = this.getCloneFrom(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected ResolvedScan cloneFrom = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setCloneFrom(ResolvedScan v) { this.cloneFrom = v; Preconditions.checkNotNull(v, "cloneFrom must not be null"); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCreateSnapshotTableStmt build() { validate(); return new ResolvedCreateSnapshotTableStmt( hintList, namePath, createScope, createMode, cloneFrom, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( cloneFrom != null, "cloneFrom must be set"); } } public static final ResolvedCreateSnapshotTableStmt deserialize( ResolvedCreateSnapshotTableStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedCreateSnapshotTableStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_SNAPSHOT_TABLE_STMT; } @Override public final String nodeKindString() { return "CreateSnapshotTableStmt"; } /** * 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(); ResolvedCreateSnapshotTableStmtProto.Builder childBuilder = ResolvedCreateSnapshotTableStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateSnapshotTableStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateSnapshotTableStmtProto.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, ResolvedCreateSnapshotTableStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // cloneFrom is an AST node. Call its serialization chain. if (this.getCloneFrom() != null) { AnyResolvedScanProto.Builder cloneFromBuilder = AnyResolvedScanProto.newBuilder(); this.getCloneFrom().serialize( fileDescriptorSetsBuilder, cloneFromBuilder); proto.setCloneFrom( cloneFromBuilder.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()); } } public final ResolvedScan getCloneFrom() { return cloneFrom; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateSnapshotTableStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(cloneFrom); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (cloneFrom != null) { fields.add(new DebugStringField("clone_from", cloneFrom)); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This statement: * CREATE [TEMP] EXTERNAL TABLE [(column type, ...)] * [DEFAULT COLLATE ] * [WITH PARTITION COLUMN [(column type, ...)]] * [WITH CONNECTION connection_name] * OPTIONS (...) */ public static final class ResolvedCreateExternalTableStmt extends ResolvedCreateTableStmtBase { private final ResolvedWithPartitionColumns withPartitionColumns; ResolvedCreateExternalTableStmt(ResolvedCreateExternalTableStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasWithPartitionColumns()) { withPartitionColumns = ResolvedWithPartitionColumns.deserialize(proto.getWithPartitionColumns(), helper); } else { withPartitionColumns = null; } } ResolvedCreateExternalTableStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ImmutableList columnDefinitionList, ImmutableList pseudoColumnList, ResolvedPrimaryKey primaryKey, ImmutableList foreignKeyList, ImmutableList checkConstraintList, boolean isValueTable, Table likeTable, ResolvedExpr collationName, ResolvedConnection connection, ResolvedWithPartitionColumns withPartitionColumns) { super( hintList, namePath, createScope, createMode, optionList, columnDefinitionList, pseudoColumnList, primaryKey, foreignKeyList, checkConstraintList, isValueTable, likeTable, collationName, connection); this.withPartitionColumns = withPartitionColumns; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); builder.columnDefinitionList = this.getColumnDefinitionList(); builder.pseudoColumnList = this.getPseudoColumnList(); builder.primaryKey = this.getPrimaryKey(); builder.foreignKeyList = this.getForeignKeyList(); builder.checkConstraintList = this.getCheckConstraintList(); builder.isValueTable = this.getIsValueTable(); builder.likeTable = this.getLikeTable(); builder.collationName = this.getCollationName(); builder.connection = this.getConnection(); builder.withPartitionColumns = this.getWithPartitionColumns(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateTableStmtBase.Builder { protected ResolvedWithPartitionColumns withPartitionColumns = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setOptionList(List v) { super.setOptionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { super.setColumnDefinitionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setPseudoColumnList(List v) { super.setPseudoColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setPrimaryKey(ResolvedPrimaryKey v) { super.setPrimaryKey(v); return this; } @Override @CanIgnoreReturnValue public Builder setForeignKeyList(List v) { super.setForeignKeyList(v); return this; } @Override @CanIgnoreReturnValue public Builder setCheckConstraintList(List v) { super.setCheckConstraintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { super.setIsValueTable(v); return this; } @Override @CanIgnoreReturnValue public Builder setLikeTable(Table v) { super.setLikeTable(v); return this; } @Override @CanIgnoreReturnValue public Builder setCollationName(ResolvedExpr v) { super.setCollationName(v); return this; } @Override @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { super.setConnection(v); return this; } @CanIgnoreReturnValue public Builder setWithPartitionColumns(ResolvedWithPartitionColumns v) { this.withPartitionColumns = v; return this; } @Override public final ResolvedCreateExternalTableStmt build() { validate(); return new ResolvedCreateExternalTableStmt( hintList, namePath, createScope, createMode, optionList, columnDefinitionList, pseudoColumnList, primaryKey, foreignKeyList, checkConstraintList, isValueTable, likeTable, collationName, connection, withPartitionColumns); } @Override protected void validate() { super.validate(); } } public static final ResolvedCreateExternalTableStmt deserialize( ResolvedCreateExternalTableStmtProto proto, AbstractDeserializationHelper 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 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(); 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. ResolvedCreateTableStmtBaseProto parent = (ResolvedCreateTableStmtBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // withPartitionColumns is an AST node. Call its serialization chain. if (this.getWithPartitionColumns() != null) { ResolvedWithPartitionColumnsProto.Builder withPartitionColumnsBuilder = ResolvedWithPartitionColumnsProto.newBuilder(); this.getWithPartitionColumns().serialize( fileDescriptorSetsBuilder, withPartitionColumnsBuilder); proto.setWithPartitionColumns( withPartitionColumnsBuilder.build()); } } public final ResolvedWithPartitionColumns getWithPartitionColumns() { return withPartitionColumns; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateExternalTableStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(withPartitionColumns); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (withPartitionColumns != null) { fields.add(new DebugStringField("with_partition_columns", withPartitionColumns)); } } } /** * This statement: * EXPORT MODEL [WITH CONNECTION ] * * which is used to export a model to a specific location. * is the connection that the model is written to. * identifies user specified options to use when exporting the * model. */ public static final class ResolvedExportModelStmt extends ResolvedStatement { private final ImmutableList modelNamePath; private final ResolvedConnection connection; private final ImmutableList optionList; ResolvedExportModelStmt(ResolvedExportModelStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); modelNamePath = ImmutableList.copyOf(proto.getModelNamePathList()); if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedExportModelStmt( ImmutableList hintList, ImmutableList modelNamePath, ResolvedConnection connection, ImmutableList optionList) { super( hintList); this.modelNamePath = modelNamePath; this.connection = connection; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.modelNamePath = this.getModelNamePath(); builder.connection = this.getConnection(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ImmutableList modelNamePath = null; protected ResolvedConnection connection = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setModelNamePath(List v) { this.modelNamePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedExportModelStmt build() { validate(); return new ResolvedExportModelStmt( hintList, modelNamePath, connection, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( modelNamePath != null, "modelNamePath must be set"); Preconditions.checkArgument( optionList != null, "optionList must be set"); } } public static final ResolvedExportModelStmt deserialize( ResolvedExportModelStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedExportModelStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXPORT_MODEL_STMT; } @Override public final String nodeKindString() { return "ExportModelStmt"; } /** * 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(); ResolvedExportModelStmtProto.Builder childBuilder = ResolvedExportModelStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExportModelStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExportModelStmtProto.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, ResolvedExportModelStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // modelNamePath 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.addAllModelNamePath(this.getModelNamePath()); // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.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()); } } public final ImmutableList getModelNamePath() { return modelNamePath; } public final ResolvedConnection getConnection() { return connection; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedExportModelStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(connection); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("model_name_path", DebugStrings.toStringImpl(modelNamePath))); } if (connection != null) { fields.add(new DebugStringField("connection", connection)); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This statement: * EXPORT DATA [WITH CONNECTION] () AS SELECT ... * or this pipe operator (without a query, in ResolvedPipeExportDataScan): * |> EXPORT DATA [WITH CONNECTION] () * *

This is used to run export a query result somewhere without giving the * result a table name. * *

connection reference for accessing destination source. * 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 (when this node is used as a statement). * When this node is used as part of ResolvedPipeExportDataScan, * is not present. The input table is the pipe input table. * *

The query must produce named columns with unique names. */ public static final class ResolvedExportDataStmt extends ResolvedStatement { private final ResolvedConnection connection; 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; /** * `query` is present when this node is used as a statement. * `query` is not present when used in ResolvedPipeExportDataScan. */ private final ResolvedScan query; ResolvedExportDataStmt(ResolvedExportDataStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } 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; } } ResolvedExportDataStmt( ImmutableList hintList, ResolvedConnection connection, ImmutableList optionList, ImmutableList outputColumnList, boolean isValueTable, ResolvedScan query) { super( hintList); this.connection = connection; this.optionList = optionList; this.outputColumnList = outputColumnList; this.isValueTable = isValueTable; this.query = query; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.connection = this.getConnection(); builder.optionList = this.getOptionList(); builder.outputColumnList = this.getOutputColumnList(); builder.isValueTable = this.getIsValueTable(); builder.query = this.getQuery(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedConnection connection = null; protected ImmutableList optionList = null; protected ImmutableList outputColumnList = null; protected Boolean isValueTable = null; protected ResolvedScan query = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } /** * 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). */ @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { this.isValueTable = v; return this; } /** * `query` is present when this node is used as a statement. * `query` is not present when used in ResolvedPipeExportDataScan. */ @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; return this; } @Override public final ResolvedExportDataStmt build() { validate(); return new ResolvedExportDataStmt( hintList, connection, optionList, outputColumnList, isValueTable, query); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( outputColumnList != null, "outputColumnList must be set"); } } public static final ResolvedExportDataStmt deserialize( ResolvedExportDataStmtProto proto, AbstractDeserializationHelper 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); // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.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()); } // 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 ResolvedConnection getConnection() { return connection; } 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; } /** * `query` is present when this node is used as a statement. * `query` is not present when used in ResolvedPipeExportDataScan. */ public final ResolvedScan getQuery() { return query; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedExportDataStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(connection); visitor.descend(optionList); visitor.descend(outputColumnList); visitor.descend(query); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (connection != null) { fields.add(new DebugStringField("connection", connection)); } 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: * EXPORT METADATA FROM * [WITH CONNECTION ] [OPTIONS()] * *

is a string identifier for the object for which the * metadata should be exported. Currently, only 'TABLE' object is supported. * is a vector giving the identifier path for the object for * which the metadata should be exported. * connection reference for accessing destination source. * identifies user specified options to use when exporting * object's metadata. */ public static final class ResolvedExportMetadataStmt extends ResolvedStatement { private final String schemaObjectKind; private final ImmutableList namePath; private final ResolvedConnection connection; private final ImmutableList optionList; ResolvedExportMetadataStmt(ResolvedExportMetadataStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); schemaObjectKind = proto.getSchemaObjectKind(); namePath = ImmutableList.copyOf(proto.getNamePathList()); if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedExportMetadataStmt( ImmutableList hintList, String schemaObjectKind, ImmutableList namePath, ResolvedConnection connection, ImmutableList optionList) { super( hintList); this.schemaObjectKind = schemaObjectKind; this.namePath = namePath; this.connection = connection; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.schemaObjectKind = this.getSchemaObjectKind(); builder.namePath = this.getNamePath(); builder.connection = this.getConnection(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected String schemaObjectKind = null; protected ImmutableList namePath = null; protected ResolvedConnection connection = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setSchemaObjectKind(String v) { this.schemaObjectKind = v; Preconditions.checkNotNull(v, "schemaObjectKind must not be null"); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedExportMetadataStmt build() { validate(); return new ResolvedExportMetadataStmt( hintList, schemaObjectKind, namePath, connection, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( schemaObjectKind != null, "schemaObjectKind must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); Preconditions.checkArgument( optionList != null, "optionList must be set"); } } public static final ResolvedExportMetadataStmt deserialize( ResolvedExportMetadataStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedExportMetadataStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXPORT_METADATA_STMT; } @Override public final String nodeKindString() { return "ExportMetadataStmt"; } /** * 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(); ResolvedExportMetadataStmtProto.Builder childBuilder = ResolvedExportMetadataStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExportMetadataStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExportMetadataStmtProto.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, ResolvedExportMetadataStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // schemaObjectKind is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setSchemaObjectKind(this.getSchemaObjectKind()); // 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()); // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.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()); } } public final String getSchemaObjectKind() { return schemaObjectKind; } public final ImmutableList getNamePath() { return namePath; } public final ResolvedConnection getConnection() { return connection; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedExportMetadataStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(connection); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("schema_object_kind", DebugStrings.toStringImpl(schemaObjectKind))); } { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (connection != null) { fields.add(new DebugStringField("connection", connection)); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * 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; ResolvedDefineTableStmt(ResolvedDefineTableStmtProto proto, AbstractDeserializationHelper 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(); } ResolvedDefineTableStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList optionList) { super( hintList); this.namePath = namePath; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ImmutableList namePath = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedDefineTableStmt build() { validate(); return new ResolvedDefineTableStmt( hintList, namePath, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( namePath != null, "namePath must be set"); Preconditions.checkArgument( optionList != null, "optionList must be set"); } } public static final ResolvedDefineTableStmt deserialize( ResolvedDefineTableStmtProto proto, AbstractDeserializationHelper 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 public ResolvedDefineTableStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public 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; ResolvedDescribeStmt(ResolvedDescribeStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); objectType = proto.getObjectType(); namePath = ImmutableList.copyOf(proto.getNamePathList()); fromNamePath = ImmutableList.copyOf(proto.getFromNamePathList()); } ResolvedDescribeStmt( ImmutableList hintList, String objectType, ImmutableList namePath, ImmutableList fromNamePath) { super( hintList); this.objectType = objectType; this.namePath = namePath; this.fromNamePath = fromNamePath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.objectType = this.getObjectType(); builder.namePath = this.getNamePath(); builder.fromNamePath = this.getFromNamePath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected String objectType = null; protected ImmutableList namePath = null; protected ImmutableList fromNamePath = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setObjectType(String v) { this.objectType = v; Preconditions.checkNotNull(v, "objectType must not be null"); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setFromNamePath(List v) { this.fromNamePath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedDescribeStmt build() { validate(); return new ResolvedDescribeStmt( hintList, objectType, namePath, fromNamePath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( objectType != null, "objectType must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedDescribeStmt deserialize( ResolvedDescribeStmtProto proto, AbstractDeserializationHelper 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 public ResolvedDescribeStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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; ResolvedShowStmt(ResolvedShowStmtProto proto, AbstractDeserializationHelper 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; } } ResolvedShowStmt( ImmutableList hintList, String identifier, ImmutableList namePath, ResolvedLiteral likeExpr) { super( hintList); this.identifier = identifier; this.namePath = namePath; this.likeExpr = likeExpr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.identifier = this.getIdentifier(); builder.namePath = this.getNamePath(); builder.likeExpr = this.getLikeExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected String identifier = null; protected ImmutableList namePath = null; protected ResolvedLiteral likeExpr = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setIdentifier(String v) { this.identifier = v; Preconditions.checkNotNull(v, "identifier must not be null"); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setLikeExpr(ResolvedLiteral v) { this.likeExpr = v; return this; } @Override public final ResolvedShowStmt build() { validate(); return new ResolvedShowStmt( hintList, identifier, namePath, likeExpr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( identifier != null, "identifier must be set"); } } public static final ResolvedShowStmt deserialize( ResolvedShowStmtProto proto, AbstractDeserializationHelper 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 public ResolvedShowStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(likeExpr); } public 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; ResolvedBeginStmt(ResolvedBeginStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); readWriteMode = proto.getReadWriteMode(); isolationLevelList = ImmutableList.copyOf(proto.getIsolationLevelListList()); } ResolvedBeginStmt( ImmutableList hintList, ReadWriteMode readWriteMode, ImmutableList isolationLevelList) { super( hintList); this.readWriteMode = readWriteMode; this.isolationLevelList = isolationLevelList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.readWriteMode = this.getReadWriteMode(); builder.isolationLevelList = this.getIsolationLevelList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ReadWriteMode readWriteMode = null; protected ImmutableList isolationLevelList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setReadWriteMode(ReadWriteMode v) { this.readWriteMode = v; return this; } @CanIgnoreReturnValue public Builder setIsolationLevelList(List v) { this.isolationLevelList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedBeginStmt build() { validate(); return new ResolvedBeginStmt( hintList, readWriteMode, isolationLevelList); } @Override protected void validate() { super.validate(); } } public static final ResolvedBeginStmt deserialize( ResolvedBeginStmtProto proto, AbstractDeserializationHelper 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 public ResolvedBeginStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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; ResolvedSetTransactionStmt(ResolvedSetTransactionStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); readWriteMode = proto.getReadWriteMode(); isolationLevelList = ImmutableList.copyOf(proto.getIsolationLevelListList()); } ResolvedSetTransactionStmt( ImmutableList hintList, ReadWriteMode readWriteMode, ImmutableList isolationLevelList) { super( hintList); this.readWriteMode = readWriteMode; this.isolationLevelList = isolationLevelList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.readWriteMode = this.getReadWriteMode(); builder.isolationLevelList = this.getIsolationLevelList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ReadWriteMode readWriteMode = null; protected ImmutableList isolationLevelList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setReadWriteMode(ReadWriteMode v) { this.readWriteMode = v; return this; } @CanIgnoreReturnValue public Builder setIsolationLevelList(List v) { this.isolationLevelList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedSetTransactionStmt build() { validate(); return new ResolvedSetTransactionStmt( hintList, readWriteMode, isolationLevelList); } @Override protected void validate() { super.validate(); } } public static final ResolvedSetTransactionStmt deserialize( ResolvedSetTransactionStmtProto proto, AbstractDeserializationHelper 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 public ResolvedSetTransactionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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 { ResolvedCommitStmt(ResolvedCommitStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedCommitStmt( ImmutableList hintList) { super( hintList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override public final ResolvedCommitStmt build() { validate(); return new ResolvedCommitStmt( hintList); } @Override protected void validate() { super.validate(); } } public static final ResolvedCommitStmt deserialize( ResolvedCommitStmtProto proto, AbstractDeserializationHelper 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 public ResolvedCommitStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: ROLLBACK [TRANSACTION]; */ public static final class ResolvedRollbackStmt extends ResolvedStatement { ResolvedRollbackStmt(ResolvedRollbackStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedRollbackStmt( ImmutableList hintList) { super( hintList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override public final ResolvedRollbackStmt build() { validate(); return new ResolvedRollbackStmt( hintList); } @Override protected void validate() { super.validate(); } } public static final ResolvedRollbackStmt deserialize( ResolvedRollbackStmtProto proto, AbstractDeserializationHelper 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 public ResolvedRollbackStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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; ResolvedStartBatchStmt(ResolvedStartBatchStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); batchType = proto.getBatchType(); } ResolvedStartBatchStmt( ImmutableList hintList, String batchType) { super( hintList); this.batchType = batchType; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.batchType = this.getBatchType(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected String batchType = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setBatchType(String v) { this.batchType = v; return this; } @Override public final ResolvedStartBatchStmt build() { validate(); return new ResolvedStartBatchStmt( hintList, batchType); } @Override protected void validate() { super.validate(); } } public static final ResolvedStartBatchStmt deserialize( ResolvedStartBatchStmtProto proto, AbstractDeserializationHelper 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 public ResolvedStartBatchStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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 { ResolvedRunBatchStmt(ResolvedRunBatchStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedRunBatchStmt( ImmutableList hintList) { super( hintList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override public final ResolvedRunBatchStmt build() { validate(); return new ResolvedRunBatchStmt( hintList); } @Override protected void validate() { super.validate(); } } public static final ResolvedRunBatchStmt deserialize( ResolvedRunBatchStmtProto proto, AbstractDeserializationHelper 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 public ResolvedRunBatchStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: ABORT BATCH; */ public static final class ResolvedAbortBatchStmt extends ResolvedStatement { ResolvedAbortBatchStmt(ResolvedAbortBatchStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAbortBatchStmt( ImmutableList hintList) { super( hintList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override public final ResolvedAbortBatchStmt build() { validate(); return new ResolvedAbortBatchStmt( hintList); } @Override protected void validate() { super.validate(); } } public static final ResolvedAbortBatchStmt deserialize( ResolvedAbortBatchStmtProto proto, AbstractDeserializationHelper 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 public ResolvedAbortBatchStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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. * specifies drop mode RESTRICT/CASCASE, if any. */ public static final class ResolvedDropStmt extends ResolvedStatement { private final String objectType; private final boolean isIfExists; private final ImmutableList namePath; private final DropMode dropMode; ResolvedDropStmt(ResolvedDropStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); objectType = proto.getObjectType(); isIfExists = proto.getIsIfExists(); namePath = ImmutableList.copyOf(proto.getNamePathList()); dropMode = proto.getDropMode(); } ResolvedDropStmt( ImmutableList hintList, String objectType, boolean isIfExists, ImmutableList namePath, DropMode dropMode) { super( hintList); this.objectType = objectType; this.isIfExists = isIfExists; this.namePath = namePath; this.dropMode = dropMode; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.objectType = this.getObjectType(); builder.isIfExists = this.getIsIfExists(); builder.namePath = this.getNamePath(); builder.dropMode = this.getDropMode(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected String objectType = null; protected Boolean isIfExists = null; protected ImmutableList namePath = null; protected DropMode dropMode = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setObjectType(String v) { this.objectType = v; Preconditions.checkNotNull(v, "objectType must not be null"); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setDropMode(DropMode v) { this.dropMode = v; return this; } @Override public final ResolvedDropStmt build() { validate(); return new ResolvedDropStmt( hintList, objectType, isIfExists, namePath, dropMode); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( objectType != null, "objectType must be set"); Preconditions.checkArgument( isIfExists != null, "isIfExists must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedDropStmt deserialize( ResolvedDropStmtProto proto, AbstractDeserializationHelper 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()); // dropMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setDropMode(this.getDropMode()); } public final String getObjectType() { return objectType; } public final boolean getIsIfExists() { return isIfExists; } public final ImmutableList getNamePath() { return namePath; } public final DropMode getDropMode() { return dropMode; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDropStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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))); } if (!DebugStrings.isDefaultValue(dropMode)) { fields.add(new DebugStringField("drop_mode", DebugStrings.toStringImpl(dropMode))); } } } /** * 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; ResolvedDropMaterializedViewStmt(ResolvedDropMaterializedViewStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); namePath = ImmutableList.copyOf(proto.getNamePathList()); } ResolvedDropMaterializedViewStmt( ImmutableList hintList, boolean isIfExists, ImmutableList namePath) { super( hintList); this.isIfExists = isIfExists; this.namePath = namePath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.isIfExists = this.getIsIfExists(); builder.namePath = this.getNamePath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected Boolean isIfExists = null; protected ImmutableList namePath = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedDropMaterializedViewStmt build() { validate(); return new ResolvedDropMaterializedViewStmt( hintList, isIfExists, namePath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfExists != null, "isIfExists must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedDropMaterializedViewStmt deserialize( ResolvedDropMaterializedViewStmtProto proto, AbstractDeserializationHelper 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 public ResolvedDropMaterializedViewStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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 statement: DROP SNAPSHOT TABLE [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 ResolvedDropSnapshotTableStmt extends ResolvedStatement { private final boolean isIfExists; private final ImmutableList namePath; ResolvedDropSnapshotTableStmt(ResolvedDropSnapshotTableStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); namePath = ImmutableList.copyOf(proto.getNamePathList()); } ResolvedDropSnapshotTableStmt( ImmutableList hintList, boolean isIfExists, ImmutableList namePath) { super( hintList); this.isIfExists = isIfExists; this.namePath = namePath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.isIfExists = this.getIsIfExists(); builder.namePath = this.getNamePath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected Boolean isIfExists = null; protected ImmutableList namePath = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedDropSnapshotTableStmt build() { validate(); return new ResolvedDropSnapshotTableStmt( hintList, isIfExists, namePath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfExists != null, "isIfExists must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedDropSnapshotTableStmt deserialize( ResolvedDropSnapshotTableStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedDropSnapshotTableStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_SNAPSHOT_TABLE_STMT; } @Override public final String nodeKindString() { return "DropSnapshotTableStmt"; } /** * 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(); ResolvedDropSnapshotTableStmtProto.Builder childBuilder = ResolvedDropSnapshotTableStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropSnapshotTableStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropSnapshotTableStmtProto.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, ResolvedDropSnapshotTableStmtProto.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 public ResolvedDropSnapshotTableStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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))); } } } /** * Scan the previous iteration of the recursive alias currently being * defined, from inside the recursive subquery which defines it. Such nodes * can exist only in the recursive term of a ResolvedRecursiveScan node. * The column_list produced here will match 1:1 with the column_list produced * by the referenced subquery and will be given a new unique name to each * column produced for this scan. */ public static final class ResolvedRecursiveRefScan extends ResolvedScan { ResolvedRecursiveRefScan(ResolvedRecursiveRefScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedRecursiveRefScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource) { super( columnList, hintList, isOrdered, nodeSource); } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override public final ResolvedRecursiveRefScan build() { validate(); return new ResolvedRecursiveRefScan( columnList, hintList, isOrdered, nodeSource); } @Override protected void validate() { super.validate(); } } public static final ResolvedRecursiveRefScan deserialize( ResolvedRecursiveRefScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedRecursiveRefScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RECURSIVE_REF_SCAN; } @Override public final String nodeKindString() { return "RecursiveRefScan"; } /** * 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(); ResolvedRecursiveRefScanProto.Builder childBuilder = ResolvedRecursiveRefScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRecursiveRefScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRecursiveRefScanProto.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, ResolvedRecursiveRefScanProto.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 public ResolvedRecursiveRefScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This represents a recursion depth modifier to recursive CTE: * WITH DEPTH [ AS ] * [ BETWEEN AND ] * *

and represents the range of iterations (both * side included) whose results are part of CTE's final output. * *

lower_bound and upper_bound are two integer literals or * query parameters. Query parameter values must be checked at run-time by * ZetaSQL compliant backend systems. * - both lower/upper_bound must be non-negative; * - lower_bound is by default zero if unspecified; * - upper_bound is by default infinity if unspecified; * - lower_bound must be smaller or equal than upper_bound; * *

is the column that represents the * recursion depth semantics: the iteration number that outputs this row; * it is part of ResolvedRecursiveScan's column list when specified, but * there is no corresponding column in the inputs of Recursive CTE. * *

See (broken link):explicit-recursion-depth for details. */ public static final class ResolvedRecursionDepthModifier extends ResolvedArgument { private final ResolvedExpr lowerBound; private final ResolvedExpr upperBound; private final ResolvedColumnHolder recursionDepthColumn; ResolvedRecursionDepthModifier(ResolvedRecursionDepthModifierProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasLowerBound()) { lowerBound = ResolvedExpr.deserialize(proto.getLowerBound(), helper); } else { lowerBound = null; } if (proto.hasUpperBound()) { upperBound = ResolvedExpr.deserialize(proto.getUpperBound(), helper); } else { upperBound = null; } if (proto.hasRecursionDepthColumn()) { recursionDepthColumn = ResolvedColumnHolder.deserialize(proto.getRecursionDepthColumn(), helper); } else { recursionDepthColumn = null; } } ResolvedRecursionDepthModifier( ResolvedExpr lowerBound, ResolvedExpr upperBound, ResolvedColumnHolder recursionDepthColumn) { super(); this.lowerBound = lowerBound; this.upperBound = upperBound; this.recursionDepthColumn = recursionDepthColumn; } @Override public Builder toBuilder() { Builder builder = builder(); builder.lowerBound = this.getLowerBound(); builder.upperBound = this.getUpperBound(); builder.recursionDepthColumn = this.getRecursionDepthColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr lowerBound = null; protected ResolvedExpr upperBound = null; protected ResolvedColumnHolder recursionDepthColumn = null; private Builder() {} @CanIgnoreReturnValue public Builder setLowerBound(ResolvedExpr v) { this.lowerBound = v; return this; } @CanIgnoreReturnValue public Builder setUpperBound(ResolvedExpr v) { this.upperBound = v; return this; } @CanIgnoreReturnValue public Builder setRecursionDepthColumn(ResolvedColumnHolder v) { this.recursionDepthColumn = v; Preconditions.checkNotNull(v, "recursionDepthColumn must not be null"); return this; } @Override public final ResolvedRecursionDepthModifier build() { validate(); return new ResolvedRecursionDepthModifier( lowerBound, upperBound, recursionDepthColumn); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( recursionDepthColumn != null, "recursionDepthColumn must be set"); } } public static final ResolvedRecursionDepthModifier deserialize( ResolvedRecursionDepthModifierProto proto, AbstractDeserializationHelper helper) { return new ResolvedRecursionDepthModifier(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RECURSION_DEPTH_MODIFIER; } @Override public final String nodeKindString() { return "RecursionDepthModifier"; } /** * 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(); ResolvedRecursionDepthModifierProto.Builder childBuilder = ResolvedRecursionDepthModifierProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRecursionDepthModifierNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRecursionDepthModifierProto.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, ResolvedRecursionDepthModifierProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // lowerBound is an AST node. Call its serialization chain. if (this.getLowerBound() != null) { AnyResolvedExprProto.Builder lowerBoundBuilder = AnyResolvedExprProto.newBuilder(); this.getLowerBound().serialize( fileDescriptorSetsBuilder, lowerBoundBuilder); proto.setLowerBound( lowerBoundBuilder.build()); } // upperBound is an AST node. Call its serialization chain. if (this.getUpperBound() != null) { AnyResolvedExprProto.Builder upperBoundBuilder = AnyResolvedExprProto.newBuilder(); this.getUpperBound().serialize( fileDescriptorSetsBuilder, upperBoundBuilder); proto.setUpperBound( upperBoundBuilder.build()); } // recursionDepthColumn is an AST node. Call its serialization chain. if (this.getRecursionDepthColumn() != null) { ResolvedColumnHolderProto.Builder recursionDepthColumnBuilder = ResolvedColumnHolderProto.newBuilder(); this.getRecursionDepthColumn().serialize( fileDescriptorSetsBuilder, recursionDepthColumnBuilder); proto.setRecursionDepthColumn( recursionDepthColumnBuilder.build()); } } public final ResolvedExpr getLowerBound() { return lowerBound; } public final ResolvedExpr getUpperBound() { return upperBound; } public final ResolvedColumnHolder getRecursionDepthColumn() { return recursionDepthColumn; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedRecursionDepthModifier accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(lowerBound); visitor.descend(upperBound); visitor.descend(recursionDepthColumn); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (lowerBound != null) { fields.add(new DebugStringField("lower_bound", lowerBound)); } if (upperBound != null) { fields.add(new DebugStringField("upper_bound", upperBound)); } if (recursionDepthColumn != null) { fields.add(new DebugStringField("recursion_depth_column", recursionDepthColumn)); } } } /** * A recursive query inside a WITH RECURSIVE or RECURSIVE VIEW. A * ResolvedRecursiveScan may appear in a resolved tree only as a top-level * input scan of a ResolvedWithEntry or ResolvedCreateViewBase. * *

Recursive queries must satisfy the form: * UNION [ALL|DISTINCT] * *

where self-references to table being defined are allowed only in the * section. * *

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 . * *

At runtime, a recursive scan is evaluated using an iterative process: * *

Step 1 (iteration 0): Evaluate the non-recursive term. If UNION DISTINCT * is specified, discard duplicates. * *

Step 2 (iteration k): * Repeat until step 2 produces an empty result: * Evaluate the recursive term, binding the recursive table to the * new rows produced by previous step (iteration k-1). * If UNION DISTINCT is specified, discard duplicate rows, as well as any * rows which match any previously-produced result. * *

Step 3: * The final content of the recursive table is the UNION ALL of all results * produced [lower_bound, upper_bound] iterations specified in the * recursion depth modifier. (which are already DISTINCT because of step 2, * if the query had UNION DISTINCT). The final content is augmented by the * column specified in the recursion depth modifier (if specified) which * represents the iteration number that the row is output. * If UNION DISTINCT is specified, the depth column represents the first * iteration that produces a given row. * The depth column will be part of the output column list. * *

When recursion_depth_modifier is unspecified, the lower bound is * effectively zero, the upper bound is infinite. * *

ResolvedRecursiveScan only supports a recursive WITH entry which * directly references itself; ZetaSQL does not support mutual recursion * between multiple with-clause elements. * *

See (broken link) for details. */ public static final class ResolvedRecursiveScan extends ResolvedScan { private final RecursiveSetOperationType opType; private final ResolvedSetOperationItem nonRecursiveTerm; private final ResolvedSetOperationItem recursiveTerm; private final ResolvedRecursionDepthModifier recursionDepthModifier; ResolvedRecursiveScan(ResolvedRecursiveScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); opType = proto.getOpType(); if (proto.hasNonRecursiveTerm()) { nonRecursiveTerm = ResolvedSetOperationItem.deserialize(proto.getNonRecursiveTerm(), helper); } else { nonRecursiveTerm = null; } if (proto.hasRecursiveTerm()) { recursiveTerm = ResolvedSetOperationItem.deserialize(proto.getRecursiveTerm(), helper); } else { recursiveTerm = null; } if (proto.hasRecursionDepthModifier()) { recursionDepthModifier = ResolvedRecursionDepthModifier.deserialize(proto.getRecursionDepthModifier(), helper); } else { recursionDepthModifier = null; } } ResolvedRecursiveScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, RecursiveSetOperationType opType, ResolvedSetOperationItem nonRecursiveTerm, ResolvedSetOperationItem recursiveTerm, ResolvedRecursionDepthModifier recursionDepthModifier) { super( columnList, hintList, isOrdered, nodeSource); this.opType = opType; this.nonRecursiveTerm = nonRecursiveTerm; this.recursiveTerm = recursiveTerm; this.recursionDepthModifier = recursionDepthModifier; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.opType = this.getOpType(); builder.nonRecursiveTerm = this.getNonRecursiveTerm(); builder.recursiveTerm = this.getRecursiveTerm(); builder.recursionDepthModifier = this.getRecursionDepthModifier(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected RecursiveSetOperationType opType = null; protected ResolvedSetOperationItem nonRecursiveTerm = null; protected ResolvedSetOperationItem recursiveTerm = null; protected ResolvedRecursionDepthModifier recursionDepthModifier = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setOpType(RecursiveSetOperationType v) { this.opType = v; Preconditions.checkNotNull(v, "opType must not be null"); return this; } @CanIgnoreReturnValue public Builder setNonRecursiveTerm(ResolvedSetOperationItem v) { this.nonRecursiveTerm = v; Preconditions.checkNotNull(v, "nonRecursiveTerm must not be null"); return this; } @CanIgnoreReturnValue public Builder setRecursiveTerm(ResolvedSetOperationItem v) { this.recursiveTerm = v; Preconditions.checkNotNull(v, "recursiveTerm must not be null"); return this; } @CanIgnoreReturnValue public Builder setRecursionDepthModifier(ResolvedRecursionDepthModifier v) { this.recursionDepthModifier = v; return this; } @Override public final ResolvedRecursiveScan build() { validate(); return new ResolvedRecursiveScan( columnList, hintList, isOrdered, nodeSource, opType, nonRecursiveTerm, recursiveTerm, recursionDepthModifier); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( opType != null, "opType must be set"); Preconditions.checkArgument( nonRecursiveTerm != null, "nonRecursiveTerm must be set"); Preconditions.checkArgument( recursiveTerm != null, "recursiveTerm must be set"); } } public static final ResolvedRecursiveScan deserialize( ResolvedRecursiveScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedRecursiveScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RECURSIVE_SCAN; } @Override public final String nodeKindString() { return "RecursiveScan"; } /** * 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(); ResolvedRecursiveScanProto.Builder childBuilder = ResolvedRecursiveScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRecursiveScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRecursiveScanProto.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, ResolvedRecursiveScanProto.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()); // nonRecursiveTerm is an AST node. Call its serialization chain. if (this.getNonRecursiveTerm() != null) { ResolvedSetOperationItemProto.Builder nonRecursiveTermBuilder = ResolvedSetOperationItemProto.newBuilder(); this.getNonRecursiveTerm().serialize( fileDescriptorSetsBuilder, nonRecursiveTermBuilder); proto.setNonRecursiveTerm( nonRecursiveTermBuilder.build()); } // recursiveTerm is an AST node. Call its serialization chain. if (this.getRecursiveTerm() != null) { ResolvedSetOperationItemProto.Builder recursiveTermBuilder = ResolvedSetOperationItemProto.newBuilder(); this.getRecursiveTerm().serialize( fileDescriptorSetsBuilder, recursiveTermBuilder); proto.setRecursiveTerm( recursiveTermBuilder.build()); } // recursionDepthModifier is an AST node. Call its serialization chain. if (this.getRecursionDepthModifier() != null) { ResolvedRecursionDepthModifierProto.Builder recursionDepthModifierBuilder = ResolvedRecursionDepthModifierProto.newBuilder(); this.getRecursionDepthModifier().serialize( fileDescriptorSetsBuilder, recursionDepthModifierBuilder); proto.setRecursionDepthModifier( recursionDepthModifierBuilder.build()); } } public final RecursiveSetOperationType getOpType() { return opType; } public final ResolvedSetOperationItem getNonRecursiveTerm() { return nonRecursiveTerm; } public final ResolvedSetOperationItem getRecursiveTerm() { return recursiveTerm; } public final ResolvedRecursionDepthModifier getRecursionDepthModifier() { return recursionDepthModifier; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedRecursiveScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(nonRecursiveTerm); visitor.descend(recursiveTerm); visitor.descend(recursionDepthModifier); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("op_type", DebugStrings.toStringImpl(opType))); } if (nonRecursiveTerm != null) { fields.add(new DebugStringField("non_recursive_term", nonRecursiveTerm)); } if (recursiveTerm != null) { fields.add(new DebugStringField("recursive_term", recursiveTerm)); } if (recursionDepthModifier != null) { fields.add(new DebugStringField("recursion_depth_modifier", recursionDepthModifier)); } } } /** * This represents a SQL WITH query (or subquery) like * WITH [RECURSIVE] AS (), * AS () * ; * *

WITH entries are sorted in dependency order so that an entry can only * reference entries earlier in , plus itself if the * RECURSIVE keyword is used. If the RECURSIVE keyword is not used, this will * be the same order as in the original query, since an entry which * references itself or any entry later in the list is not allowed. * *

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. * *

In ZetaSQL 1.3 (language option FEATURE_V_1_3_WITH_RECURSIVE), WITH * RECURSIVE is supported, which allows any to reference * any , regardless of order, including WITH entries which * reference themself. Circular dependency chains of WITH entries are allowed * only for direct self-references, and only when the corresponding * takes the form " UNION [ALL|DISTINCT] * ", with all references to the current * confined to the recursive term. * *

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. */ public static final class ResolvedWithScan extends ResolvedScan { private final ImmutableList withEntryList; private final ResolvedScan query; /** * True if the WITH clause uses the recursive keyword. */ private final boolean recursive; ResolvedWithScan(ResolvedWithScanProto proto, AbstractDeserializationHelper 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; } recursive = proto.getRecursive(); } ResolvedWithScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ImmutableList withEntryList, ResolvedScan query, boolean recursive) { super( columnList, hintList, isOrdered, nodeSource); this.withEntryList = withEntryList; this.query = query; this.recursive = recursive; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.withEntryList = this.getWithEntryList(); builder.query = this.getQuery(); builder.recursive = this.getRecursive(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ImmutableList withEntryList = null; protected ResolvedScan query = null; protected Boolean recursive = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setWithEntryList(List v) { this.withEntryList = ImmutableList.copyOf(v); return this; } /** * Note: this method propagates the 'isOrdered' field from {@param v}. * To override this, call setIsOrdered explicitly after calling this * method. */ @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; Preconditions.checkNotNull(v, "query must not be null"); setIsOrdered(v.getIsOrdered()); return this; } /** * True if the WITH clause uses the recursive keyword. */ @CanIgnoreReturnValue public Builder setRecursive(boolean v) { this.recursive = v; return this; } @Override public final ResolvedWithScan build() { validate(); return new ResolvedWithScan( columnList, hintList, isOrdered, nodeSource, withEntryList, query, recursive); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( withEntryList != null, "withEntryList must be set"); Preconditions.checkArgument( query != null, "query must be set"); } } public static final ResolvedWithScan deserialize( ResolvedWithScanProto proto, AbstractDeserializationHelper 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()); } // recursive is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setRecursive(this.getRecursive()); } public final ImmutableList getWithEntryList() { return withEntryList; } public final ResolvedScan getQuery() { return query; } /** * True if the WITH clause uses the recursive keyword. */ public final boolean getRecursive() { return recursive; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedWithScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(withEntryList); visitor.descend(query); } public 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)); } if (!DebugStrings.isDefaultValue(recursive)) { fields.add(new DebugStringField("recursive", DebugStrings.toStringImpl(recursive))); } } } /** * 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; ResolvedWithEntry(ResolvedWithEntryProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); withQueryName = proto.getWithQueryName(); if (proto.hasWithSubquery()) { withSubquery = ResolvedScan.deserialize(proto.getWithSubquery(), helper); } else { withSubquery = null; } } ResolvedWithEntry( String withQueryName, ResolvedScan withSubquery) { super(); this.withQueryName = withQueryName; this.withSubquery = withSubquery; } @Override public Builder toBuilder() { Builder builder = builder(); builder.withQueryName = this.getWithQueryName(); builder.withSubquery = this.getWithSubquery(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String withQueryName = null; protected ResolvedScan withSubquery = null; private Builder() {} @CanIgnoreReturnValue public Builder setWithQueryName(String v) { this.withQueryName = v; Preconditions.checkNotNull(v, "withQueryName must not be null"); return this; } @CanIgnoreReturnValue public Builder setWithSubquery(ResolvedScan v) { this.withSubquery = v; Preconditions.checkNotNull(v, "withSubquery must not be null"); return this; } @Override public final ResolvedWithEntry build() { validate(); return new ResolvedWithEntry( withQueryName, withSubquery); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( withQueryName != null, "withQueryName must be set"); Preconditions.checkArgument( withSubquery != null, "withSubquery must be set"); } } public static final ResolvedWithEntry deserialize( ResolvedWithEntryProto proto, AbstractDeserializationHelper 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 public ResolvedWithEntry accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(withSubquery); } public 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 or option 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 or option 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). * is an enum that indicates the assignment operation for * array type options. * *

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. For assignment_op that's not the default * value, also checks whether the expected type is Array and whether * allow_alter_array is true. Unknown hints and options(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. * *

is set only for hints, and will always be empty in options * lists. * *

will always be DEFAULT_ASSIGN (i.e. "=") for hints, and * defaults to the same value for options. Can be set to * ADD_ASSIGN ("+=") and SUB_ASSIGN ("-=") for options with * Array type. * *

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; private final AssignmentOp assignmentOp; ResolvedOption(ResolvedOptionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); qualifier = proto.getQualifier(); name = proto.getName(); if (proto.hasValue()) { value = ResolvedExpr.deserialize(proto.getValue(), helper); } else { value = null; } assignmentOp = proto.getAssignmentOp(); } ResolvedOption( String qualifier, String name, ResolvedExpr value, AssignmentOp assignmentOp) { super(); this.qualifier = qualifier; this.name = name; this.value = value; this.assignmentOp = assignmentOp; } @Override public Builder toBuilder() { Builder builder = builder(); builder.qualifier = this.getQualifier(); builder.name = this.getName(); builder.value = this.getValue(); builder.assignmentOp = this.getAssignmentOp(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String qualifier = null; protected String name = null; protected ResolvedExpr value = null; protected AssignmentOp assignmentOp = AssignmentOp.DEFAULT_ASSIGN; private Builder() {} @CanIgnoreReturnValue public Builder setQualifier(String v) { this.qualifier = v; return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; return this; } @CanIgnoreReturnValue public Builder setValue(ResolvedExpr v) { this.value = v; return this; } @CanIgnoreReturnValue public Builder setAssignmentOp(AssignmentOp v) { this.assignmentOp = v; return this; } @Override public final ResolvedOption build() { validate(); return new ResolvedOption( qualifier, name, value, assignmentOp); } @Override protected void validate() { super.validate(); } } public static final ResolvedOption deserialize( ResolvedOptionProto proto, AbstractDeserializationHelper 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()); } // assignmentOp is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setAssignmentOp(this.getAssignmentOp()); } public final String getQualifier() { return qualifier; } public final String getName() { return name; } public final ResolvedExpr getValue() { return value; } public final AssignmentOp getAssignmentOp() { return assignmentOp; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedOption accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(value); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * Window partitioning specification for an analytic function call. * *

PARTITION BY keys in . * *

is either empty to indicate that all the elements in * have the default collation, or has * the same number of elements as . Each element is the * collation for the element in with the same index, or * can be empty to indicate default collation or when the type is not * collatable. is only set when * FEATURE_V_1_3_COLLATION_SUPPORT is enabled. * See (broken link). */ public static final class ResolvedWindowPartitioning extends ResolvedArgument { private final ImmutableList partitionByList; private final ImmutableList hintList; private final ImmutableList collationList; ResolvedWindowPartitioning(ResolvedWindowPartitioningProto proto, AbstractDeserializationHelper 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(); ImmutableList.Builder collationListBuilder = ImmutableList.builder(); for (ResolvedCollationProto element : proto.getCollationListList()) { collationListBuilder.add(helper.deserialize(element)); } collationList = collationListBuilder.build(); } ResolvedWindowPartitioning( ImmutableList partitionByList, ImmutableList hintList, ImmutableList collationList) { super(); this.partitionByList = partitionByList; this.hintList = hintList; this.collationList = collationList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.partitionByList = this.getPartitionByList(); builder.hintList = this.getHintList(); builder.collationList = this.getCollationList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList partitionByList = null; protected ImmutableList hintList = ImmutableList.of(); protected ImmutableList collationList = ImmutableList.of(); private Builder() {} @CanIgnoreReturnValue public Builder setPartitionByList(List v) { this.partitionByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setHintList(List v) { this.hintList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setCollationList(List v) { this.collationList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedWindowPartitioning build() { validate(); return new ResolvedWindowPartitioning( partitionByList, hintList, collationList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( partitionByList != null, "partitionByList must be set"); } } public static final ResolvedWindowPartitioning deserialize( ResolvedWindowPartitioningProto proto, AbstractDeserializationHelper 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()); } // collationList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList collationLists = this.getCollationList(); for (ResolvedCollation element : collationLists) { proto.addCollationList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } } public final ImmutableList getPartitionByList() { return partitionByList; } public final ImmutableList getHintList() { return hintList; } public final ImmutableList getCollationList() { return collationList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedWindowPartitioning accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(partitionByList); visitor.descend(hintList); } public 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)); } if (!DebugStrings.isDefaultValue(collationList)) { fields.add(new DebugStringField("collation_list", DebugStrings.toStringCommaSeparated(collationList))); } } } /** * 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; ResolvedWindowOrdering(ResolvedWindowOrderingProto proto, AbstractDeserializationHelper 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(); } ResolvedWindowOrdering( ImmutableList orderByItemList, ImmutableList hintList) { super(); this.orderByItemList = orderByItemList; this.hintList = hintList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.orderByItemList = this.getOrderByItemList(); builder.hintList = this.getHintList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList orderByItemList = null; protected ImmutableList hintList = ImmutableList.of(); private Builder() {} @CanIgnoreReturnValue public Builder setOrderByItemList(List v) { this.orderByItemList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setHintList(List v) { this.hintList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedWindowOrdering build() { validate(); return new ResolvedWindowOrdering( orderByItemList, hintList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( orderByItemList != null, "orderByItemList must be set"); } } public static final ResolvedWindowOrdering deserialize( ResolvedWindowOrderingProto proto, AbstractDeserializationHelper 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 public ResolvedWindowOrdering accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(orderByItemList); visitor.descend(hintList); } public 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; ResolvedWindowFrame(ResolvedWindowFrameProto proto, AbstractDeserializationHelper 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; } } ResolvedWindowFrame( FrameUnit frameUnit, ResolvedWindowFrameExpr startExpr, ResolvedWindowFrameExpr endExpr) { super(); this.frameUnit = frameUnit; this.startExpr = startExpr; this.endExpr = endExpr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.frameUnit = this.getFrameUnit(); builder.startExpr = this.getStartExpr(); builder.endExpr = this.getEndExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected FrameUnit frameUnit = null; protected ResolvedWindowFrameExpr startExpr = null; protected ResolvedWindowFrameExpr endExpr = null; private Builder() {} @CanIgnoreReturnValue public Builder setFrameUnit(FrameUnit v) { this.frameUnit = v; Preconditions.checkNotNull(v, "frameUnit must not be null"); return this; } @CanIgnoreReturnValue public Builder setStartExpr(ResolvedWindowFrameExpr v) { this.startExpr = v; Preconditions.checkNotNull(v, "startExpr must not be null"); return this; } @CanIgnoreReturnValue public Builder setEndExpr(ResolvedWindowFrameExpr v) { this.endExpr = v; Preconditions.checkNotNull(v, "endExpr must not be null"); return this; } @Override public final ResolvedWindowFrame build() { validate(); return new ResolvedWindowFrame( frameUnit, startExpr, endExpr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( frameUnit != null, "frameUnit must be set"); Preconditions.checkArgument( startExpr != null, "startExpr must be set"); Preconditions.checkArgument( endExpr != null, "endExpr must be set"); } } public static final ResolvedWindowFrame deserialize( ResolvedWindowFrameProto proto, AbstractDeserializationHelper 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 public ResolvedWindowFrame accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(startExpr); visitor.descend(endExpr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public 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 * ResolvedAnalyticFunctionCall 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; ResolvedAnalyticFunctionGroup(ResolvedAnalyticFunctionGroupProto proto, AbstractDeserializationHelper 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 (AnyResolvedComputedColumnBaseProto element : proto.getAnalyticFunctionListList()) { analyticFunctionListBuilder .add(ResolvedComputedColumnBase.deserialize(element, helper)); } analyticFunctionList = analyticFunctionListBuilder.build(); } ResolvedAnalyticFunctionGroup( ResolvedWindowPartitioning partitionBy, ResolvedWindowOrdering orderBy, ImmutableList analyticFunctionList) { super(); this.partitionBy = partitionBy; this.orderBy = orderBy; this.analyticFunctionList = analyticFunctionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.partitionBy = this.getPartitionBy(); builder.orderBy = this.getOrderBy(); builder.analyticFunctionList = this.getAnalyticFunctionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedWindowPartitioning partitionBy = null; protected ResolvedWindowOrdering orderBy = null; protected ImmutableList analyticFunctionList = null; private Builder() {} @CanIgnoreReturnValue public Builder setPartitionBy(ResolvedWindowPartitioning v) { this.partitionBy = v; Preconditions.checkNotNull(v, "partitionBy must not be null"); return this; } @CanIgnoreReturnValue public Builder setOrderBy(ResolvedWindowOrdering v) { this.orderBy = v; Preconditions.checkNotNull(v, "orderBy must not be null"); return this; } @CanIgnoreReturnValue public Builder setAnalyticFunctionList(List v) { this.analyticFunctionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedAnalyticFunctionGroup build() { validate(); return new ResolvedAnalyticFunctionGroup( partitionBy, orderBy, analyticFunctionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( partitionBy != null, "partitionBy must be set"); Preconditions.checkArgument( orderBy != null, "orderBy must be set"); Preconditions.checkArgument( analyticFunctionList != null, "analyticFunctionList must be set"); } } public static final ResolvedAnalyticFunctionGroup deserialize( ResolvedAnalyticFunctionGroupProto proto, AbstractDeserializationHelper 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 (ResolvedComputedColumnBase element : analyticFunctionLists) { AnyResolvedComputedColumnBaseProto.Builder analyticFunctionListBuilder = AnyResolvedComputedColumnBaseProto.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 public ResolvedAnalyticFunctionGroup accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(partitionBy); visitor.descend(orderBy); visitor.descend(analyticFunctionList); } public 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; ResolvedWindowFrameExpr(ResolvedWindowFrameExprProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); boundaryType = proto.getBoundaryType(); if (proto.hasExpression()) { expression = ResolvedExpr.deserialize(proto.getExpression(), helper); } else { expression = null; } } ResolvedWindowFrameExpr( BoundaryType boundaryType, ResolvedExpr expression) { super(); this.boundaryType = boundaryType; this.expression = expression; } @Override public Builder toBuilder() { Builder builder = builder(); builder.boundaryType = this.getBoundaryType(); builder.expression = this.getExpression(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected BoundaryType boundaryType = null; protected ResolvedExpr expression = null; private Builder() {} @CanIgnoreReturnValue public Builder setBoundaryType(BoundaryType v) { this.boundaryType = v; Preconditions.checkNotNull(v, "boundaryType must not be null"); return this; } @CanIgnoreReturnValue public Builder setExpression(ResolvedExpr v) { this.expression = v; Preconditions.checkNotNull(v, "expression must not be null"); return this; } @Override public final ResolvedWindowFrameExpr build() { validate(); return new ResolvedWindowFrameExpr( boundaryType, expression); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( boundaryType != null, "boundaryType must be set"); Preconditions.checkArgument( expression != null, "expression must be set"); } } public static final ResolvedWindowFrameExpr deserialize( ResolvedWindowFrameExprProto proto, AbstractDeserializationHelper 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 public ResolvedWindowFrameExpr accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public 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; ResolvedDMLValue(ResolvedDMLValueProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasValue()) { value = ResolvedExpr.deserialize(proto.getValue(), helper); } else { value = null; } } ResolvedDMLValue( ResolvedExpr value) { super(); this.value = value; } @Override public Builder toBuilder() { Builder builder = builder(); builder.value = this.getValue(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr value = null; private Builder() {} @CanIgnoreReturnValue public Builder setValue(ResolvedExpr v) { this.value = v; Preconditions.checkNotNull(v, "value must not be null"); return this; } @Override public final ResolvedDMLValue build() { validate(); return new ResolvedDMLValue( value); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( value != null, "value must be set"); } } public static final ResolvedDMLValue deserialize( ResolvedDMLValueProto proto, AbstractDeserializationHelper 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 public ResolvedDMLValue accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(value); } public 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 { ResolvedDMLDefault(ResolvedDMLDefaultProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedDMLDefault( Type type, AnnotationMap typeAnnotationMap) { super( type, typeAnnotationMap); } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @Override public final ResolvedDMLDefault build() { validate(); return new ResolvedDMLDefault( type, typeAnnotationMap); } @Override protected void validate() { super.validate(); } } public static final ResolvedDMLDefault deserialize( ResolvedDMLDefaultProto proto, AbstractDeserializationHelper 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 public ResolvedDMLDefault accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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; ResolvedAssertStmt(ResolvedAssertStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpression()) { expression = ResolvedExpr.deserialize(proto.getExpression(), helper); } else { expression = null; } description = proto.getDescription(); } ResolvedAssertStmt( ImmutableList hintList, ResolvedExpr expression, String description) { super( hintList); this.expression = expression; this.description = description; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.expression = this.getExpression(); builder.description = this.getDescription(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedExpr expression = null; protected String description = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setExpression(ResolvedExpr v) { this.expression = v; Preconditions.checkNotNull(v, "expression must not be null"); return this; } @CanIgnoreReturnValue public Builder setDescription(String v) { this.description = v; return this; } @Override public final ResolvedAssertStmt build() { validate(); return new ResolvedAssertStmt( hintList, expression, description); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expression != null, "expression must be set"); } } public static final ResolvedAssertStmt deserialize( ResolvedAssertStmtProto proto, AbstractDeserializationHelper 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 public ResolvedAssertStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); } public 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; ResolvedAssertRowsModified(ResolvedAssertRowsModifiedProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasRows()) { rows = ResolvedExpr.deserialize(proto.getRows(), helper); } else { rows = null; } } ResolvedAssertRowsModified( ResolvedExpr rows) { super(); this.rows = rows; } @Override public Builder toBuilder() { Builder builder = builder(); builder.rows = this.getRows(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr rows = null; private Builder() {} @CanIgnoreReturnValue public Builder setRows(ResolvedExpr v) { this.rows = v; Preconditions.checkNotNull(v, "rows must not be null"); return this; } @Override public final ResolvedAssertRowsModified build() { validate(); return new ResolvedAssertRowsModified( rows); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( rows != null, "rows must be set"); } } public static final ResolvedAssertRowsModified deserialize( ResolvedAssertRowsModifiedProto proto, AbstractDeserializationHelper 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 public ResolvedAssertRowsModified accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(rows); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (rows != null) { fields.add(new DebugStringField("rows", rows)); } } } /** * This represents the ON CONFLICT clause on an INSERT statement. It * specifies the alternate action to be taken if the insert row causes * unique constraint violations. * *

is the action to take if the insert row causes unique * constraint violations. Either NOTHING to ignore the insert row or UPDATE * to update the original table row with the constraint values. * *

is the list of columns to infer a unique * constraint - primary key or UNIQUE columns - for which the uniqueness * should be arbitrated. ZetaSQL only resolves them into valid column * references. It is the engine's responsibility to validate and infer * a unique constraint. See "Conflict target" section in * (broken link), http://shortn/_4GrUbFPEKm * *

is the name of the UNIQUE constraint instead of * specifying the columns in conflict target. ZetaSQL only resolves it as * a valid identifier. It is the engine's responsibility to infer a UNIQUE * constraint. See "Conflict target" section in * (broken link). http://shortn/_4GrUbFPEKm * *

is a ResolvedTableScan on the target table. It returns * the new rows that were constructed to be inserted where the insert failed * with a conflict, using the underlying Table's columns. * The included columns are the columns from insert row referenced * in the update SET RHS expression and/or the update WHERE clause using * the `excluded` alias. It can also include generated columns or columns not * in the INSERT column list. * This is applicable only for conflict action UPDATE. It's null if the * conflict action is NOTHING. * *

is the list of update items if the conflict action is * UPDATE. They are refer columns in both the insert row and original table * row. * *

is used to conditionally update the table row if * the conflict action is UPDATE. */ public static final class ResolvedOnConflictClause extends ResolvedArgument { private final ConflictAction conflictAction; /** * IGNORABLE_DEFAULT because this is an optional field for NOTHING * conflict action. It is also empty if unique constraint name * is specified. */ private final ImmutableList conflictTargetColumnList; /** * IGNORABLE_DEFAULT because this is an optional field for NOTHING * conflict action. It is also empty if conflict target is specified. */ private final String uniqueConstraintName; /** * IGNORABLE_DEFAULT because this is set for UPDATE conflict action * only and if update_item_list and/or update_where_expression * reference columns from the insert row using `excluded` alias. */ private final ResolvedTableScan insertRowScan; /** * IGNORABLE_DEFAULT because this is set for UPDATE conflict action * only. */ private final ImmutableList updateItemList; /** * IGNORABLE_DEFAULT because this is set for UPDATE conflict action * only. */ private final ResolvedExpr updateWhereExpression; ResolvedOnConflictClause(ResolvedOnConflictClauseProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); conflictAction = proto.getConflictAction(); ImmutableList.Builder conflictTargetColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getConflictTargetColumnListList()) { conflictTargetColumnListBuilder.add(helper.deserialize(element)); } conflictTargetColumnList = conflictTargetColumnListBuilder.build(); uniqueConstraintName = proto.getUniqueConstraintName(); if (proto.hasInsertRowScan()) { insertRowScan = ResolvedTableScan.deserialize(proto.getInsertRowScan(), helper); } else { insertRowScan = null; } ImmutableList.Builder updateItemListBuilder = ImmutableList.builder(); for (ResolvedUpdateItemProto element : proto.getUpdateItemListList()) { updateItemListBuilder .add(ResolvedUpdateItem.deserialize(element, helper)); } updateItemList = updateItemListBuilder.build(); if (proto.hasUpdateWhereExpression()) { updateWhereExpression = ResolvedExpr.deserialize(proto.getUpdateWhereExpression(), helper); } else { updateWhereExpression = null; } } ResolvedOnConflictClause( ConflictAction conflictAction, ImmutableList conflictTargetColumnList, String uniqueConstraintName, ResolvedTableScan insertRowScan, ImmutableList updateItemList, ResolvedExpr updateWhereExpression) { super(); this.conflictAction = conflictAction; this.conflictTargetColumnList = conflictTargetColumnList; this.uniqueConstraintName = uniqueConstraintName; this.insertRowScan = insertRowScan; this.updateItemList = updateItemList; this.updateWhereExpression = updateWhereExpression; } @Override public Builder toBuilder() { Builder builder = builder(); builder.conflictAction = this.getConflictAction(); builder.conflictTargetColumnList = this.getConflictTargetColumnList(); builder.uniqueConstraintName = this.getUniqueConstraintName(); builder.insertRowScan = this.getInsertRowScan(); builder.updateItemList = this.getUpdateItemList(); builder.updateWhereExpression = this.getUpdateWhereExpression(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ConflictAction conflictAction = null; protected ImmutableList conflictTargetColumnList = null; protected String uniqueConstraintName = null; protected ResolvedTableScan insertRowScan = null; protected ImmutableList updateItemList = null; protected ResolvedExpr updateWhereExpression = null; private Builder() {} @CanIgnoreReturnValue public Builder setConflictAction(ConflictAction v) { this.conflictAction = v; Preconditions.checkNotNull(v, "conflictAction must not be null"); return this; } /** * IGNORABLE_DEFAULT because this is an optional field for NOTHING * conflict action. It is also empty if unique constraint name * is specified. */ @CanIgnoreReturnValue public Builder setConflictTargetColumnList(List v) { this.conflictTargetColumnList = ImmutableList.copyOf(v); return this; } /** * IGNORABLE_DEFAULT because this is an optional field for NOTHING * conflict action. It is also empty if conflict target is specified. */ @CanIgnoreReturnValue public Builder setUniqueConstraintName(String v) { this.uniqueConstraintName = v; return this; } /** * IGNORABLE_DEFAULT because this is set for UPDATE conflict action * only and if update_item_list and/or update_where_expression * reference columns from the insert row using `excluded` alias. */ @CanIgnoreReturnValue public Builder setInsertRowScan(ResolvedTableScan v) { this.insertRowScan = v; return this; } /** * IGNORABLE_DEFAULT because this is set for UPDATE conflict action * only. */ @CanIgnoreReturnValue public Builder setUpdateItemList(List v) { this.updateItemList = ImmutableList.copyOf(v); return this; } /** * IGNORABLE_DEFAULT because this is set for UPDATE conflict action * only. */ @CanIgnoreReturnValue public Builder setUpdateWhereExpression(ResolvedExpr v) { this.updateWhereExpression = v; return this; } @Override public final ResolvedOnConflictClause build() { validate(); return new ResolvedOnConflictClause( conflictAction, conflictTargetColumnList, uniqueConstraintName, insertRowScan, updateItemList, updateWhereExpression); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( conflictAction != null, "conflictAction must be set"); } } public static final ResolvedOnConflictClause deserialize( ResolvedOnConflictClauseProto proto, AbstractDeserializationHelper helper) { return new ResolvedOnConflictClause(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ON_CONFLICT_CLAUSE; } @Override public final String nodeKindString() { return "OnConflictClause"; } /** * 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(); ResolvedOnConflictClauseProto.Builder childBuilder = ResolvedOnConflictClauseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedOnConflictClauseNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedOnConflictClauseProto.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, ResolvedOnConflictClauseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // conflictAction is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setConflictAction(this.getConflictAction()); // conflictTargetColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList conflictTargetColumnLists = this.getConflictTargetColumnList(); for (ResolvedColumn element : conflictTargetColumnLists) { proto.addConflictTargetColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // uniqueConstraintName is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setUniqueConstraintName(this.getUniqueConstraintName()); // insertRowScan is an AST node. Call its serialization chain. if (this.getInsertRowScan() != null) { ResolvedTableScanProto.Builder insertRowScanBuilder = ResolvedTableScanProto.newBuilder(); this.getInsertRowScan().serialize( fileDescriptorSetsBuilder, insertRowScanBuilder); proto.setInsertRowScan( insertRowScanBuilder.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()); } // updateWhereExpression is an AST node. Call its serialization chain. if (this.getUpdateWhereExpression() != null) { AnyResolvedExprProto.Builder updateWhereExpressionBuilder = AnyResolvedExprProto.newBuilder(); this.getUpdateWhereExpression().serialize( fileDescriptorSetsBuilder, updateWhereExpressionBuilder); proto.setUpdateWhereExpression( updateWhereExpressionBuilder.build()); } } public final ConflictAction getConflictAction() { return conflictAction; } /** * IGNORABLE_DEFAULT because this is an optional field for NOTHING * conflict action. It is also empty if unique constraint name * is specified. */ public final ImmutableList getConflictTargetColumnList() { return conflictTargetColumnList; } /** * IGNORABLE_DEFAULT because this is an optional field for NOTHING * conflict action. It is also empty if conflict target is specified. */ public final String getUniqueConstraintName() { return uniqueConstraintName; } /** * IGNORABLE_DEFAULT because this is set for UPDATE conflict action * only and if update_item_list and/or update_where_expression * reference columns from the insert row using `excluded` alias. */ public final ResolvedTableScan getInsertRowScan() { return insertRowScan; } /** * IGNORABLE_DEFAULT because this is set for UPDATE conflict action * only. */ public final ImmutableList getUpdateItemList() { return updateItemList; } /** * IGNORABLE_DEFAULT because this is set for UPDATE conflict action * only. */ public final ResolvedExpr getUpdateWhereExpression() { return updateWhereExpression; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedOnConflictClause accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(insertRowScan); visitor.descend(updateItemList); visitor.descend(updateWhereExpression); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("conflict_action", DebugStrings.toStringImpl(conflictAction))); } if (!DebugStrings.isDefaultValue(conflictTargetColumnList)) { fields.add(new DebugStringField("conflict_target_column_list", DebugStrings.toStringImpl(conflictTargetColumnList))); } if (!DebugStrings.isDefaultValue(uniqueConstraintName)) { fields.add(new DebugStringField("unique_constraint_name", DebugStrings.toStringImpl(uniqueConstraintName))); } if (insertRowScan != null) { fields.add(new DebugStringField("insert_row_scan", insertRowScan)); } if (!updateItemList.isEmpty()) { fields.add(new DebugStringField("update_item_list", updateItemList)); } if (updateWhereExpression != null) { fields.add(new DebugStringField("update_where_expression", updateWhereExpression)); } } } /** * This represents one row in the VALUES clause of an INSERT. */ public static final class ResolvedInsertRow extends ResolvedArgument { private final ImmutableList valueList; ResolvedInsertRow(ResolvedInsertRowProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder valueListBuilder = ImmutableList.builder(); for (ResolvedDMLValueProto element : proto.getValueListList()) { valueListBuilder .add(ResolvedDMLValue.deserialize(element, helper)); } valueList = valueListBuilder.build(); } ResolvedInsertRow( ImmutableList valueList) { super(); this.valueList = valueList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.valueList = this.getValueList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList valueList = null; private Builder() {} @CanIgnoreReturnValue public Builder setValueList(List v) { this.valueList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedInsertRow build() { validate(); return new ResolvedInsertRow( valueList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( valueList != null, "valueList must be set"); } } public static final ResolvedInsertRow deserialize( ResolvedInsertRowProto proto, AbstractDeserializationHelper 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 public ResolvedInsertRow accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(valueList); } public 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. * *

If is present, the INSERT statement will return newly inserted * rows. can only occur on top-level statements. * *

The returning clause has a to represent the data * sent back to clients. It can only access columns from the . * *

is set for queries to * tables having generated columns. It provides the resolved column ids of * the generated columns in topological order, which the computed generated * column expressions can be computed in. * *

has generated expressions for the corresponding * generated column in the topologically_sorted_generated_column_id_list. * Hence, these lists have the same size. * *

indicates for each column in * whether it was read and/or written. The query engine may also require * read or write permissions across all columns, including unreferenced * columns, depending on the operation. * *

specifies the alternate action if the insert row * causes unique constraint violations. It handles violations in both primary * key and UNIQUE constraints. Alternate actions are (1) to do nothing * (ignore the insert row), or (2) update the original table row using the * specified SET clauses and the optional WHERE clause. */ 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 ResolvedReturningClause returning; private final ImmutableList insertColumnList; private final ImmutableList queryParameterList; private final ResolvedScan query; private final ImmutableList queryOutputColumnList; private final ImmutableList rowList; private final ImmutableList columnAccessList; private final ResolvedOnConflictClause onConflictClause; /** * This returns a topologically sorted list of generated columns * resolved ids in the table accessed by insert statement. * For example for below table * CREATE TABLE T( * k1 INT64 NOT NULL, * data INT64, * gen1 INT64 AS data+1, * gen2 INT64 AS gen1*2, * gen3 INT64 AS data*2 + gen1, * ) PRIMARY KEY(k1); * data------------------->gen1--------------------->gen2 * * *----------> * * * ------------------------------->gen3 * the vector would have corresponding indexes of one of these values * gen1 gen2 gen3 OR gen1 gen3 gen2. */ private final ImmutableList topologicallySortedGeneratedColumnIdList; /** * This field returns the vector of generated column expressions * corresponding to the column ids in * topologically_sorted_generated_column_id_list. Both the lists have * the same size and 1-to-1 mapping for the column id with its * corresponding expression. This field is not directly accessed * from the catalog since these expressions are rewritten to replace * the ResolvedExpressionColumn for the referred columns in the * catalog to corresponding ResolvedColumnRef. */ private final ImmutableList generatedColumnExprList; ResolvedInsertStmt(ResolvedInsertStmtProto proto, AbstractDeserializationHelper 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; } if (proto.hasReturning()) { returning = ResolvedReturningClause.deserialize(proto.getReturning(), helper); } else { returning = 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(); columnAccessList = ImmutableList.copyOf(proto.getColumnAccessListList()); if (proto.hasOnConflictClause()) { onConflictClause = ResolvedOnConflictClause.deserialize(proto.getOnConflictClause(), helper); } else { onConflictClause = null; } topologicallySortedGeneratedColumnIdList = ImmutableList.copyOf(proto.getTopologicallySortedGeneratedColumnIdListList()); ImmutableList.Builder generatedColumnExprListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getGeneratedColumnExprListList()) { generatedColumnExprListBuilder .add(ResolvedExpr.deserialize(element, helper)); } generatedColumnExprList = generatedColumnExprListBuilder.build(); } ResolvedInsertStmt( ImmutableList hintList, ResolvedTableScan tableScan, InsertMode insertMode, ResolvedAssertRowsModified assertRowsModified, ResolvedReturningClause returning, ImmutableList insertColumnList, ImmutableList queryParameterList, ResolvedScan query, ImmutableList queryOutputColumnList, ImmutableList rowList, ImmutableList columnAccessList, ResolvedOnConflictClause onConflictClause, ImmutableList topologicallySortedGeneratedColumnIdList, ImmutableList generatedColumnExprList) { super( hintList); this.tableScan = tableScan; this.insertMode = insertMode; this.assertRowsModified = assertRowsModified; this.returning = returning; this.insertColumnList = insertColumnList; this.queryParameterList = queryParameterList; this.query = query; this.queryOutputColumnList = queryOutputColumnList; this.rowList = rowList; this.columnAccessList = columnAccessList; this.onConflictClause = onConflictClause; this.topologicallySortedGeneratedColumnIdList = topologicallySortedGeneratedColumnIdList; this.generatedColumnExprList = generatedColumnExprList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.tableScan = this.getTableScan(); builder.insertMode = this.getInsertMode(); builder.assertRowsModified = this.getAssertRowsModified(); builder.returning = this.getReturning(); builder.insertColumnList = this.getInsertColumnList(); builder.queryParameterList = this.getQueryParameterList(); builder.query = this.getQuery(); builder.queryOutputColumnList = this.getQueryOutputColumnList(); builder.rowList = this.getRowList(); builder.columnAccessList = this.getColumnAccessList(); builder.onConflictClause = this.getOnConflictClause(); builder.topologicallySortedGeneratedColumnIdList = this.getTopologicallySortedGeneratedColumnIdList(); builder.generatedColumnExprList = this.getGeneratedColumnExprList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedTableScan tableScan = null; protected InsertMode insertMode = null; protected ResolvedAssertRowsModified assertRowsModified = null; protected ResolvedReturningClause returning = null; protected ImmutableList insertColumnList = null; protected ImmutableList queryParameterList = null; protected ResolvedScan query = null; protected ImmutableList queryOutputColumnList = null; protected ImmutableList rowList = null; protected ImmutableList columnAccessList = ImmutableList.of(); protected ResolvedOnConflictClause onConflictClause = null; protected ImmutableList topologicallySortedGeneratedColumnIdList = ImmutableList.of(); protected ImmutableList generatedColumnExprList = ImmutableList.of(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setTableScan(ResolvedTableScan v) { this.tableScan = v; return this; } /** * Behavior on duplicate rows (normally defined to mean duplicate * primary keys). */ @CanIgnoreReturnValue public Builder setInsertMode(InsertMode v) { this.insertMode = v; return this; } @CanIgnoreReturnValue public Builder setAssertRowsModified(ResolvedAssertRowsModified v) { this.assertRowsModified = v; return this; } @CanIgnoreReturnValue public Builder setReturning(ResolvedReturningClause v) { this.returning = v; return this; } @CanIgnoreReturnValue public Builder setInsertColumnList(List v) { this.insertColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setQueryParameterList(List v) { this.queryParameterList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; return this; } @CanIgnoreReturnValue public Builder setQueryOutputColumnList(List v) { this.queryOutputColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setRowList(List v) { this.rowList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setColumnAccessList(List v) { this.columnAccessList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOnConflictClause(ResolvedOnConflictClause v) { this.onConflictClause = v; return this; } /** * This returns a topologically sorted list of generated columns * resolved ids in the table accessed by insert statement. * For example for below table * CREATE TABLE T( * k1 INT64 NOT NULL, * data INT64, * gen1 INT64 AS data+1, * gen2 INT64 AS gen1*2, * gen3 INT64 AS data*2 + gen1, * ) PRIMARY KEY(k1); * data------------------->gen1--------------------->gen2 * * *----------> * * * ------------------------------->gen3 * the vector would have corresponding indexes of one of these values * gen1 gen2 gen3 OR gen1 gen3 gen2. */ @CanIgnoreReturnValue public Builder setTopologicallySortedGeneratedColumnIdList(List v) { this.topologicallySortedGeneratedColumnIdList = ImmutableList.copyOf(v); return this; } /** * This field returns the vector of generated column expressions * corresponding to the column ids in * topologically_sorted_generated_column_id_list. Both the lists have * the same size and 1-to-1 mapping for the column id with its * corresponding expression. This field is not directly accessed * from the catalog since these expressions are rewritten to replace * the ResolvedExpressionColumn for the referred columns in the * catalog to corresponding ResolvedColumnRef. */ @CanIgnoreReturnValue public Builder setGeneratedColumnExprList(List v) { this.generatedColumnExprList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedInsertStmt build() { validate(); return new ResolvedInsertStmt( hintList, tableScan, insertMode, assertRowsModified, returning, insertColumnList, queryParameterList, query, queryOutputColumnList, rowList, columnAccessList, onConflictClause, topologicallySortedGeneratedColumnIdList, generatedColumnExprList); } @Override protected void validate() { super.validate(); } } public static final ResolvedInsertStmt deserialize( ResolvedInsertStmtProto proto, AbstractDeserializationHelper 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()); } // returning is an AST node. Call its serialization chain. if (this.getReturning() != null) { ResolvedReturningClauseProto.Builder returningBuilder = ResolvedReturningClauseProto.newBuilder(); this.getReturning().serialize( fileDescriptorSetsBuilder, returningBuilder); proto.setReturning( returningBuilder.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()); } // 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()); // onConflictClause is an AST node. Call its serialization chain. if (this.getOnConflictClause() != null) { ResolvedOnConflictClauseProto.Builder onConflictClauseBuilder = ResolvedOnConflictClauseProto.newBuilder(); this.getOnConflictClause().serialize( fileDescriptorSetsBuilder, onConflictClauseBuilder); proto.setOnConflictClause( onConflictClauseBuilder.build()); } // topologicallySortedGeneratedColumnIdList 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.addAllTopologicallySortedGeneratedColumnIdList(this.getTopologicallySortedGeneratedColumnIdList()); // generatedColumnExprList is a collection of AST nodes. Serialize each of them. ImmutableList generatedColumnExprLists = this.getGeneratedColumnExprList(); for (ResolvedExpr element : generatedColumnExprLists) { AnyResolvedExprProto.Builder generatedColumnExprListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, generatedColumnExprListBuilder); proto.addGeneratedColumnExprList(generatedColumnExprListBuilder.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 ResolvedReturningClause getReturning() { return returning; } 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; } public final ImmutableList getColumnAccessList() { return columnAccessList; } public final ResolvedOnConflictClause getOnConflictClause() { return onConflictClause; } /** * This returns a topologically sorted list of generated columns * resolved ids in the table accessed by insert statement. * For example for below table * CREATE TABLE T( * k1 INT64 NOT NULL, * data INT64, * gen1 INT64 AS data+1, * gen2 INT64 AS gen1*2, * gen3 INT64 AS data*2 + gen1, * ) PRIMARY KEY(k1); * data------------------->gen1--------------------->gen2 * * *----------> * * * ------------------------------->gen3 * the vector would have corresponding indexes of one of these values * gen1 gen2 gen3 OR gen1 gen3 gen2. */ public final ImmutableList getTopologicallySortedGeneratedColumnIdList() { return topologicallySortedGeneratedColumnIdList; } /** * This field returns the vector of generated column expressions * corresponding to the column ids in * topologically_sorted_generated_column_id_list. Both the lists have * the same size and 1-to-1 mapping for the column id with its * corresponding expression. This field is not directly accessed * from the catalog since these expressions are rewritten to replace * the ResolvedExpressionColumn for the referred columns in the * catalog to corresponding ResolvedColumnRef. */ public final ImmutableList getGeneratedColumnExprList() { return generatedColumnExprList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedInsertStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(assertRowsModified); visitor.descend(returning); visitor.descend(queryParameterList); visitor.descend(query); visitor.descend(rowList); visitor.descend(onConflictClause); visitor.descend(generatedColumnExprList); } public 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 (returning != null) { fields.add(new DebugStringField("returning", returning)); } 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)); } if (!DebugStrings.isDefaultValue(columnAccessList)) { fields.add(new DebugStringField("column_access_list", DebugStrings.toStringObjectAccess(columnAccessList))); } if (onConflictClause != null) { fields.add(new DebugStringField("on_conflict_clause", onConflictClause)); } if (!DebugStrings.isDefaultValue(topologicallySortedGeneratedColumnIdList)) { fields.add(new DebugStringField("topologically_sorted_generated_column_id_list", DebugStrings.toStringCommaSeparatedForInt(topologicallySortedGeneratedColumnIdList))); } if (!generatedColumnExprList.isEmpty()) { fields.add(new DebugStringField("generated_column_expr_list", generatedColumnExprList)); } } } /** * 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. * *

If is present, the DELETE statement will return deleted rows * back. It can only occur on top-level statements. * *

This returning clause has a to represent the data * sent back to clients. It can only access columns from the . * *

indicates for each column in * whether it was read and/or written. The query engine may also require * read or write permissions across all columns, including unreferenced * columns, depending on the operation. */ public static final class ResolvedDeleteStmt extends ResolvedStatement { private final ResolvedTableScan tableScan; private final ResolvedAssertRowsModified assertRowsModified; private final ResolvedReturningClause returning; private final ImmutableList columnAccessList; private final ResolvedColumnHolder arrayOffsetColumn; private final ResolvedExpr whereExpr; ResolvedDeleteStmt(ResolvedDeleteStmtProto proto, AbstractDeserializationHelper 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.hasReturning()) { returning = ResolvedReturningClause.deserialize(proto.getReturning(), helper); } else { returning = null; } columnAccessList = ImmutableList.copyOf(proto.getColumnAccessListList()); if (proto.hasArrayOffsetColumn()) { arrayOffsetColumn = ResolvedColumnHolder.deserialize(proto.getArrayOffsetColumn(), helper); } else { arrayOffsetColumn = null; } if (proto.hasWhereExpr()) { whereExpr = ResolvedExpr.deserialize(proto.getWhereExpr(), helper); } else { whereExpr = null; } } ResolvedDeleteStmt( ImmutableList hintList, ResolvedTableScan tableScan, ResolvedAssertRowsModified assertRowsModified, ResolvedReturningClause returning, ImmutableList columnAccessList, ResolvedColumnHolder arrayOffsetColumn, ResolvedExpr whereExpr) { super( hintList); this.tableScan = tableScan; this.assertRowsModified = assertRowsModified; this.returning = returning; this.columnAccessList = columnAccessList; this.arrayOffsetColumn = arrayOffsetColumn; this.whereExpr = whereExpr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.tableScan = this.getTableScan(); builder.assertRowsModified = this.getAssertRowsModified(); builder.returning = this.getReturning(); builder.columnAccessList = this.getColumnAccessList(); builder.arrayOffsetColumn = this.getArrayOffsetColumn(); builder.whereExpr = this.getWhereExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedTableScan tableScan = null; protected ResolvedAssertRowsModified assertRowsModified = null; protected ResolvedReturningClause returning = null; protected ImmutableList columnAccessList = ImmutableList.of(); protected ResolvedColumnHolder arrayOffsetColumn = null; protected ResolvedExpr whereExpr = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setTableScan(ResolvedTableScan v) { this.tableScan = v; return this; } @CanIgnoreReturnValue public Builder setAssertRowsModified(ResolvedAssertRowsModified v) { this.assertRowsModified = v; return this; } @CanIgnoreReturnValue public Builder setReturning(ResolvedReturningClause v) { this.returning = v; return this; } @CanIgnoreReturnValue public Builder setColumnAccessList(List v) { this.columnAccessList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setArrayOffsetColumn(ResolvedColumnHolder v) { this.arrayOffsetColumn = v; return this; } @CanIgnoreReturnValue public Builder setWhereExpr(ResolvedExpr v) { this.whereExpr = v; Preconditions.checkNotNull(v, "whereExpr must not be null"); return this; } @Override public final ResolvedDeleteStmt build() { validate(); return new ResolvedDeleteStmt( hintList, tableScan, assertRowsModified, returning, columnAccessList, arrayOffsetColumn, whereExpr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( whereExpr != null, "whereExpr must be set"); } } public static final ResolvedDeleteStmt deserialize( ResolvedDeleteStmtProto proto, AbstractDeserializationHelper 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()); } // returning is an AST node. Call its serialization chain. if (this.getReturning() != null) { ResolvedReturningClauseProto.Builder returningBuilder = ResolvedReturningClauseProto.newBuilder(); this.getReturning().serialize( fileDescriptorSetsBuilder, returningBuilder); proto.setReturning( returningBuilder.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()); // 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 ResolvedReturningClause getReturning() { return returning; } public final ImmutableList getColumnAccessList() { return columnAccessList; } public final ResolvedColumnHolder getArrayOffsetColumn() { return arrayOffsetColumn; } public final ResolvedExpr getWhereExpr() { return whereExpr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDeleteStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(assertRowsModified); visitor.descend(returning); visitor.descend(arrayOffsetColumn); visitor.descend(whereExpr); } public 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 (returning != null) { fields.add(new DebugStringField("returning", returning)); } if (!DebugStrings.isDefaultValue(columnAccessList)) { fields.add(new DebugStringField("column_access_list", DebugStrings.toStringObjectAccess(columnAccessList))); } 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; ResolvedUpdateItem(ResolvedUpdateItemProto proto, AbstractDeserializationHelper 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(); } ResolvedUpdateItem( ResolvedExpr target, ResolvedDMLValue setValue, ResolvedColumnHolder elementColumn, ImmutableList arrayUpdateList, ImmutableList deleteList, ImmutableList updateList, ImmutableList insertList) { super(); this.target = target; this.setValue = setValue; this.elementColumn = elementColumn; this.arrayUpdateList = arrayUpdateList; this.deleteList = deleteList; this.updateList = updateList; this.insertList = insertList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.target = this.getTarget(); builder.setValue = this.getSetValue(); builder.elementColumn = this.getElementColumn(); builder.arrayUpdateList = this.getArrayUpdateList(); builder.deleteList = this.getDeleteList(); builder.updateList = this.getUpdateList(); builder.insertList = this.getInsertList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr target = null; protected ResolvedDMLValue setValue = null; protected ResolvedColumnHolder elementColumn = null; protected ImmutableList arrayUpdateList = null; protected ImmutableList deleteList = null; protected ImmutableList updateList = null; protected ImmutableList insertList = null; private Builder() {} /** * 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. */ @CanIgnoreReturnValue public Builder setTarget(ResolvedExpr v) { this.target = v; Preconditions.checkNotNull(v, "target must not be null"); return this; } /** * 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. */ @CanIgnoreReturnValue public Builder setSetValue(ResolvedDMLValue v) { this.setValue = v; return this; } /** * 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. */ @CanIgnoreReturnValue public Builder setElementColumn(ResolvedColumnHolder v) { this.elementColumn = v; Preconditions.checkNotNull(v, "elementColumn must not be null"); return this; } /** * 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 = ... */ @CanIgnoreReturnValue public Builder setArrayUpdateList(List v) { this.arrayUpdateList = ImmutableList.copyOf(v); return this; } /** * 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. */ @CanIgnoreReturnValue public Builder setDeleteList(List v) { this.deleteList = ImmutableList.copyOf(v); return this; } /** * 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. */ @CanIgnoreReturnValue public Builder setUpdateList(List v) { this.updateList = ImmutableList.copyOf(v); return this; } /** * 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. */ @CanIgnoreReturnValue public Builder setInsertList(List v) { this.insertList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedUpdateItem build() { validate(); return new ResolvedUpdateItem( target, setValue, elementColumn, arrayUpdateList, deleteList, updateList, insertList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( target != null, "target must be set"); Preconditions.checkArgument( elementColumn != null, "elementColumn must be set"); } } public static final ResolvedUpdateItem deserialize( ResolvedUpdateItemProto proto, AbstractDeserializationHelper 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 public ResolvedUpdateItem accept(RewritingVisitor visitor) { return 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); } public 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; ResolvedUpdateArrayItem(ResolvedUpdateArrayItemProto proto, AbstractDeserializationHelper 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; } } ResolvedUpdateArrayItem( ResolvedExpr offset, ResolvedUpdateItem updateItem) { super(); this.offset = offset; this.updateItem = updateItem; } @Override public Builder toBuilder() { Builder builder = builder(); builder.offset = this.getOffset(); builder.updateItem = this.getUpdateItem(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr offset = null; protected ResolvedUpdateItem updateItem = null; private Builder() {} /** * The array offset to be modified. */ @CanIgnoreReturnValue public Builder setOffset(ResolvedExpr v) { this.offset = v; Preconditions.checkNotNull(v, "offset must not be null"); return this; } /** * The modification to perform to the array element. */ @CanIgnoreReturnValue public Builder setUpdateItem(ResolvedUpdateItem v) { this.updateItem = v; Preconditions.checkNotNull(v, "updateItem must not be null"); return this; } @Override public final ResolvedUpdateArrayItem build() { validate(); return new ResolvedUpdateArrayItem( offset, updateItem); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( offset != null, "offset must be set"); Preconditions.checkArgument( updateItem != null, "updateItem must be set"); } } public static final ResolvedUpdateArrayItem deserialize( ResolvedUpdateArrayItemProto proto, AbstractDeserializationHelper 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 public ResolvedUpdateArrayItem accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(offset); visitor.descend(updateItem); } public 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. * *

If is present, the UPDATE statement will return updated rows. * can only occur on top-level statements. * *

This returning clause has a to represent the data * sent back to clients. It can only access columns from the . * The columns in are not allowed. * TODO: allow columns in to be referenced. * *

is set for queries to * tables having generated columns. This field is similar to the INSERT case, * more details can be found in ResolvedInsertStmt. * *

has generated expressions for the corresponding * generated column in the topologically_sorted_generated_column_id_list. * Hence, these lists have the same size. This field is similar to the * INSERT case, more details can be found in ResolvedInsertStmt. */ public static final class ResolvedUpdateStmt extends ResolvedStatement { private final ResolvedTableScan tableScan; private final ImmutableList columnAccessList; private final ResolvedAssertRowsModified assertRowsModified; private final ResolvedReturningClause returning; private final ResolvedColumnHolder arrayOffsetColumn; private final ResolvedExpr whereExpr; private final ImmutableList updateItemList; private final ResolvedScan fromScan; /** * TODO: refactor it with INSERT case. */ private final ImmutableList topologicallySortedGeneratedColumnIdList; /** * TODO: refactor it with INSERT case. */ private final ImmutableList generatedColumnExprList; ResolvedUpdateStmt(ResolvedUpdateStmtProto proto, AbstractDeserializationHelper 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.hasReturning()) { returning = ResolvedReturningClause.deserialize(proto.getReturning(), helper); } else { returning = 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; } topologicallySortedGeneratedColumnIdList = ImmutableList.copyOf(proto.getTopologicallySortedGeneratedColumnIdListList()); ImmutableList.Builder generatedColumnExprListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getGeneratedColumnExprListList()) { generatedColumnExprListBuilder .add(ResolvedExpr.deserialize(element, helper)); } generatedColumnExprList = generatedColumnExprListBuilder.build(); } ResolvedUpdateStmt( ImmutableList hintList, ResolvedTableScan tableScan, ImmutableList columnAccessList, ResolvedAssertRowsModified assertRowsModified, ResolvedReturningClause returning, ResolvedColumnHolder arrayOffsetColumn, ResolvedExpr whereExpr, ImmutableList updateItemList, ResolvedScan fromScan, ImmutableList topologicallySortedGeneratedColumnIdList, ImmutableList generatedColumnExprList) { super( hintList); this.tableScan = tableScan; this.columnAccessList = columnAccessList; this.assertRowsModified = assertRowsModified; this.returning = returning; this.arrayOffsetColumn = arrayOffsetColumn; this.whereExpr = whereExpr; this.updateItemList = updateItemList; this.fromScan = fromScan; this.topologicallySortedGeneratedColumnIdList = topologicallySortedGeneratedColumnIdList; this.generatedColumnExprList = generatedColumnExprList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.tableScan = this.getTableScan(); builder.columnAccessList = this.getColumnAccessList(); builder.assertRowsModified = this.getAssertRowsModified(); builder.returning = this.getReturning(); builder.arrayOffsetColumn = this.getArrayOffsetColumn(); builder.whereExpr = this.getWhereExpr(); builder.updateItemList = this.getUpdateItemList(); builder.fromScan = this.getFromScan(); builder.topologicallySortedGeneratedColumnIdList = this.getTopologicallySortedGeneratedColumnIdList(); builder.generatedColumnExprList = this.getGeneratedColumnExprList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedTableScan tableScan = null; protected ImmutableList columnAccessList = ImmutableList.of(); protected ResolvedAssertRowsModified assertRowsModified = null; protected ResolvedReturningClause returning = null; protected ResolvedColumnHolder arrayOffsetColumn = null; protected ResolvedExpr whereExpr = null; protected ImmutableList updateItemList = null; protected ResolvedScan fromScan = null; protected ImmutableList topologicallySortedGeneratedColumnIdList = ImmutableList.of(); protected ImmutableList generatedColumnExprList = ImmutableList.of(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setTableScan(ResolvedTableScan v) { this.tableScan = v; return this; } @CanIgnoreReturnValue public Builder setColumnAccessList(List v) { this.columnAccessList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setAssertRowsModified(ResolvedAssertRowsModified v) { this.assertRowsModified = v; return this; } @CanIgnoreReturnValue public Builder setReturning(ResolvedReturningClause v) { this.returning = v; return this; } @CanIgnoreReturnValue public Builder setArrayOffsetColumn(ResolvedColumnHolder v) { this.arrayOffsetColumn = v; return this; } @CanIgnoreReturnValue public Builder setWhereExpr(ResolvedExpr v) { this.whereExpr = v; Preconditions.checkNotNull(v, "whereExpr must not be null"); return this; } @CanIgnoreReturnValue public Builder setUpdateItemList(List v) { this.updateItemList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setFromScan(ResolvedScan v) { this.fromScan = v; return this; } /** * TODO: refactor it with INSERT case. */ @CanIgnoreReturnValue public Builder setTopologicallySortedGeneratedColumnIdList(List v) { this.topologicallySortedGeneratedColumnIdList = ImmutableList.copyOf(v); return this; } /** * TODO: refactor it with INSERT case. */ @CanIgnoreReturnValue public Builder setGeneratedColumnExprList(List v) { this.generatedColumnExprList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedUpdateStmt build() { validate(); return new ResolvedUpdateStmt( hintList, tableScan, columnAccessList, assertRowsModified, returning, arrayOffsetColumn, whereExpr, updateItemList, fromScan, topologicallySortedGeneratedColumnIdList, generatedColumnExprList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( whereExpr != null, "whereExpr must be set"); Preconditions.checkArgument( updateItemList != null, "updateItemList must be set"); } } public static final ResolvedUpdateStmt deserialize( ResolvedUpdateStmtProto proto, AbstractDeserializationHelper 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()); } // returning is an AST node. Call its serialization chain. if (this.getReturning() != null) { ResolvedReturningClauseProto.Builder returningBuilder = ResolvedReturningClauseProto.newBuilder(); this.getReturning().serialize( fileDescriptorSetsBuilder, returningBuilder); proto.setReturning( returningBuilder.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()); } // topologicallySortedGeneratedColumnIdList 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.addAllTopologicallySortedGeneratedColumnIdList(this.getTopologicallySortedGeneratedColumnIdList()); // generatedColumnExprList is a collection of AST nodes. Serialize each of them. ImmutableList generatedColumnExprLists = this.getGeneratedColumnExprList(); for (ResolvedExpr element : generatedColumnExprLists) { AnyResolvedExprProto.Builder generatedColumnExprListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, generatedColumnExprListBuilder); proto.addGeneratedColumnExprList(generatedColumnExprListBuilder.build()); } } public final ResolvedTableScan getTableScan() { return tableScan; } public final ImmutableList getColumnAccessList() { return columnAccessList; } public final ResolvedAssertRowsModified getAssertRowsModified() { return assertRowsModified; } public final ResolvedReturningClause getReturning() { return returning; } public final ResolvedColumnHolder getArrayOffsetColumn() { return arrayOffsetColumn; } public final ResolvedExpr getWhereExpr() { return whereExpr; } public final ImmutableList getUpdateItemList() { return updateItemList; } public final ResolvedScan getFromScan() { return fromScan; } /** * TODO: refactor it with INSERT case. */ public final ImmutableList getTopologicallySortedGeneratedColumnIdList() { return topologicallySortedGeneratedColumnIdList; } /** * TODO: refactor it with INSERT case. */ public final ImmutableList getGeneratedColumnExprList() { return generatedColumnExprList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedUpdateStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(assertRowsModified); visitor.descend(returning); visitor.descend(arrayOffsetColumn); visitor.descend(whereExpr); visitor.descend(updateItemList); visitor.descend(fromScan); visitor.descend(generatedColumnExprList); } public 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 (returning != null) { fields.add(new DebugStringField("returning", returning)); } 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)); } if (!DebugStrings.isDefaultValue(topologicallySortedGeneratedColumnIdList)) { fields.add(new DebugStringField("topologically_sorted_generated_column_id_list", DebugStrings.toStringCommaSeparatedForInt(topologicallySortedGeneratedColumnIdList))); } if (!generatedColumnExprList.isEmpty()) { fields.add(new DebugStringField("generated_column_expr_list", generatedColumnExprList)); } } } /** * 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; ResolvedMergeWhen(ResolvedMergeWhenProto proto, AbstractDeserializationHelper 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(); } ResolvedMergeWhen( MatchType matchType, ResolvedExpr matchExpr, ActionType actionType, ImmutableList insertColumnList, ResolvedInsertRow insertRow, ImmutableList updateItemList) { super(); this.matchType = matchType; this.matchExpr = matchExpr; this.actionType = actionType; this.insertColumnList = insertColumnList; this.insertRow = insertRow; this.updateItemList = updateItemList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.matchType = this.getMatchType(); builder.matchExpr = this.getMatchExpr(); builder.actionType = this.getActionType(); builder.insertColumnList = this.getInsertColumnList(); builder.insertRow = this.getInsertRow(); builder.updateItemList = this.getUpdateItemList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected MatchType matchType = null; protected ResolvedExpr matchExpr = null; protected ActionType actionType = null; protected ImmutableList insertColumnList = null; protected ResolvedInsertRow insertRow = null; protected ImmutableList updateItemList = null; private Builder() {} @CanIgnoreReturnValue public Builder setMatchType(MatchType v) { this.matchType = v; Preconditions.checkNotNull(v, "matchType must not be null"); return this; } @CanIgnoreReturnValue public Builder setMatchExpr(ResolvedExpr v) { this.matchExpr = v; Preconditions.checkNotNull(v, "matchExpr must not be null"); return this; } @CanIgnoreReturnValue public Builder setActionType(ActionType v) { this.actionType = v; Preconditions.checkNotNull(v, "actionType must not be null"); return this; } @CanIgnoreReturnValue public Builder setInsertColumnList(List v) { this.insertColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setInsertRow(ResolvedInsertRow v) { this.insertRow = v; return this; } @CanIgnoreReturnValue public Builder setUpdateItemList(List v) { this.updateItemList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedMergeWhen build() { validate(); return new ResolvedMergeWhen( matchType, matchExpr, actionType, insertColumnList, insertRow, updateItemList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( matchType != null, "matchType must be set"); Preconditions.checkArgument( matchExpr != null, "matchExpr must be set"); Preconditions.checkArgument( actionType != null, "actionType must be set"); } } public static final ResolvedMergeWhen deserialize( ResolvedMergeWhenProto proto, AbstractDeserializationHelper 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 public ResolvedMergeWhen accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(matchExpr); visitor.descend(insertRow); visitor.descend(updateItemList); } public 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; ResolvedMergeStmt(ResolvedMergeStmtProto proto, AbstractDeserializationHelper 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(); } ResolvedMergeStmt( ImmutableList hintList, ResolvedTableScan tableScan, ImmutableList columnAccessList, ResolvedScan fromScan, ResolvedExpr mergeExpr, ImmutableList whenClauseList) { super( hintList); this.tableScan = tableScan; this.columnAccessList = columnAccessList; this.fromScan = fromScan; this.mergeExpr = mergeExpr; this.whenClauseList = whenClauseList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.tableScan = this.getTableScan(); builder.columnAccessList = this.getColumnAccessList(); builder.fromScan = this.getFromScan(); builder.mergeExpr = this.getMergeExpr(); builder.whenClauseList = this.getWhenClauseList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedTableScan tableScan = null; protected ImmutableList columnAccessList = ImmutableList.of(); protected ResolvedScan fromScan = null; protected ResolvedExpr mergeExpr = null; protected ImmutableList whenClauseList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setTableScan(ResolvedTableScan v) { this.tableScan = v; Preconditions.checkNotNull(v, "tableScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setColumnAccessList(List v) { this.columnAccessList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setFromScan(ResolvedScan v) { this.fromScan = v; Preconditions.checkNotNull(v, "fromScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setMergeExpr(ResolvedExpr v) { this.mergeExpr = v; Preconditions.checkNotNull(v, "mergeExpr must not be null"); return this; } @CanIgnoreReturnValue public Builder setWhenClauseList(List v) { this.whenClauseList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedMergeStmt build() { validate(); return new ResolvedMergeStmt( hintList, tableScan, columnAccessList, fromScan, mergeExpr, whenClauseList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( tableScan != null, "tableScan must be set"); Preconditions.checkArgument( fromScan != null, "fromScan must be set"); Preconditions.checkArgument( mergeExpr != null, "mergeExpr must be set"); Preconditions.checkArgument( whenClauseList != null, "whenClauseList must be set"); } } public static final ResolvedMergeStmt deserialize( ResolvedMergeStmtProto proto, AbstractDeserializationHelper 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 public ResolvedMergeStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(fromScan); visitor.descend(mergeExpr); visitor.descend(whenClauseList); } public 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; ResolvedTruncateStmt(ResolvedTruncateStmtProto proto, AbstractDeserializationHelper 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; } } ResolvedTruncateStmt( ImmutableList hintList, ResolvedTableScan tableScan, ResolvedExpr whereExpr) { super( hintList); this.tableScan = tableScan; this.whereExpr = whereExpr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.tableScan = this.getTableScan(); builder.whereExpr = this.getWhereExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedTableScan tableScan = null; protected ResolvedExpr whereExpr = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setTableScan(ResolvedTableScan v) { this.tableScan = v; Preconditions.checkNotNull(v, "tableScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setWhereExpr(ResolvedExpr v) { this.whereExpr = v; Preconditions.checkNotNull(v, "whereExpr must not be null"); return this; } @Override public final ResolvedTruncateStmt build() { validate(); return new ResolvedTruncateStmt( hintList, tableScan, whereExpr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( tableScan != null, "tableScan must be set"); Preconditions.checkArgument( whereExpr != null, "whereExpr must be set"); } } public static final ResolvedTruncateStmt deserialize( ResolvedTruncateStmtProto proto, AbstractDeserializationHelper 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 public ResolvedTruncateStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); visitor.descend(whereExpr); } public 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 reference to a unit of an object (e.g. a column or field of a table). * *

is a vector giving the identifier path of the object unit. */ public static final class ResolvedObjectUnit extends ResolvedArgument { private final ImmutableList namePath; ResolvedObjectUnit(ResolvedObjectUnitProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); namePath = ImmutableList.copyOf(proto.getNamePathList()); } ResolvedObjectUnit( ImmutableList namePath) { super(); this.namePath = namePath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.namePath = this.getNamePath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList namePath = null; private Builder() {} @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedObjectUnit build() { validate(); return new ResolvedObjectUnit( namePath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedObjectUnit deserialize( ResolvedObjectUnitProto proto, AbstractDeserializationHelper helper) { return new ResolvedObjectUnit(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_OBJECT_UNIT; } @Override public final String nodeKindString() { return "ObjectUnit"; } /** * 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(); ResolvedObjectUnitProto.Builder childBuilder = ResolvedObjectUnitProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedObjectUnitNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedObjectUnitProto.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, ResolvedObjectUnitProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) 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()); } public final ImmutableList getNamePath() { return namePath; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedObjectUnit accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } } } /** * 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, fields in a value table) that the privilege is scoped to. The * privilege is on the whole object if the list is empty. */ public static final class ResolvedPrivilege extends ResolvedArgument { private final String actionType; private final ImmutableList unitList; ResolvedPrivilege(ResolvedPrivilegeProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); actionType = proto.getActionType(); ImmutableList.Builder unitListBuilder = ImmutableList.builder(); for (ResolvedObjectUnitProto element : proto.getUnitListList()) { unitListBuilder .add(ResolvedObjectUnit.deserialize(element, helper)); } unitList = unitListBuilder.build(); } ResolvedPrivilege( String actionType, ImmutableList unitList) { super(); this.actionType = actionType; this.unitList = unitList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.actionType = this.getActionType(); builder.unitList = this.getUnitList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String actionType = null; protected ImmutableList unitList = null; private Builder() {} @CanIgnoreReturnValue public Builder setActionType(String v) { this.actionType = v; Preconditions.checkNotNull(v, "actionType must not be null"); return this; } @CanIgnoreReturnValue public Builder setUnitList(List v) { this.unitList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedPrivilege build() { validate(); return new ResolvedPrivilege( actionType, unitList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( actionType != null, "actionType must be set"); Preconditions.checkArgument( unitList != null, "unitList must be set"); } } public static final ResolvedPrivilege deserialize( ResolvedPrivilegeProto proto, AbstractDeserializationHelper 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 AST nodes. Serialize each of them. ImmutableList unitLists = this.getUnitList(); for (ResolvedObjectUnit element : unitLists) { ResolvedObjectUnitProto.Builder unitListBuilder = ResolvedObjectUnitProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, unitListBuilder); proto.addUnitList(unitListBuilder.build()); } } public final String getActionType() { return actionType; } public final ImmutableList getUnitList() { return unitList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedPrivilege accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(unitList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("action_type", DebugStrings.toStringImpl(actionType))); } if (!unitList.isEmpty()) { fields.add(new DebugStringField("unit_list", unitList)); } } } /** * Common superclass of GRANT/REVOKE statements. * *

is the list of privileges to be granted/revoked. ALL * PRIVILEGES should be granted/revoked if it is empty. * is an optional list of string identifiers, e.g., TABLE, * VIEW, MATERIALIZED 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 ImmutableList objectTypeList; private final ImmutableList namePath; private final ImmutableList granteeList; private final ImmutableList granteeExprList; ResolvedGrantOrRevokeStmt(ResolvedGrantOrRevokeStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder privilegeListBuilder = ImmutableList.builder(); for (ResolvedPrivilegeProto element : proto.getPrivilegeListList()) { privilegeListBuilder .add(ResolvedPrivilege.deserialize(element, helper)); } privilegeList = privilegeListBuilder.build(); objectTypeList = ImmutableList.copyOf(proto.getObjectTypeListList()); 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(); } ResolvedGrantOrRevokeStmt( ImmutableList hintList, ImmutableList privilegeList, ImmutableList objectTypeList, ImmutableList namePath, ImmutableList granteeList, ImmutableList granteeExprList) { super( hintList); this.privilegeList = privilegeList; this.objectTypeList = objectTypeList; this.namePath = namePath; this.granteeList = granteeList; this.granteeExprList = granteeExprList; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedStatement.Builder { protected ImmutableList privilegeList = null; protected ImmutableList objectTypeList = null; protected ImmutableList namePath = null; protected ImmutableList granteeList = null; protected ImmutableList granteeExprList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setPrivilegeList(List v) { this.privilegeList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setObjectTypeList(List v) { this.objectTypeList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setGranteeList(List v) { this.granteeList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setGranteeExprList(List v) { this.granteeExprList = ImmutableList.copyOf(v); return this; } @Override public abstract ResolvedGrantOrRevokeStmt build(); @Override protected void validate() { super.validate(); Preconditions.checkArgument( privilegeList != null, "privilegeList must be set"); Preconditions.checkArgument( objectTypeList != null, "objectTypeList must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static ResolvedGrantOrRevokeStmt deserialize( AnyResolvedGrantOrRevokeStmtProto proto, AbstractDeserializationHelper 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()); } // objectTypeList 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.addAllObjectTypeList(this.getObjectTypeList()); // 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 ImmutableList getObjectTypeList() { return objectTypeList; } public final ImmutableList getNamePath() { return namePath; } public final ImmutableList getGranteeList() { return granteeList; } public final ImmutableList getGranteeExprList() { return granteeExprList; } @Override public abstract ResolvedGrantOrRevokeStmt accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(privilegeList); visitor.descend(granteeExprList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!privilegeList.isEmpty()) { fields.add(new DebugStringField("privilege_list", privilegeList)); } { fields.add(new DebugStringField("object_type_list", DebugStrings.toStringImpl(objectTypeList))); } { 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 { ResolvedGrantStmt(ResolvedGrantStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedGrantStmt( ImmutableList hintList, ImmutableList privilegeList, ImmutableList objectTypeList, ImmutableList namePath, ImmutableList granteeList, ImmutableList granteeExprList) { super( hintList, privilegeList, objectTypeList, namePath, granteeList, granteeExprList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.privilegeList = this.getPrivilegeList(); builder.objectTypeList = this.getObjectTypeList(); builder.namePath = this.getNamePath(); builder.granteeList = this.getGranteeList(); builder.granteeExprList = this.getGranteeExprList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGrantOrRevokeStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setPrivilegeList(List v) { super.setPrivilegeList(v); return this; } @Override @CanIgnoreReturnValue public Builder setObjectTypeList(List v) { super.setObjectTypeList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setGranteeList(List v) { super.setGranteeList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGranteeExprList(List v) { super.setGranteeExprList(v); return this; } @Override public final ResolvedGrantStmt build() { validate(); return new ResolvedGrantStmt( hintList, privilegeList, objectTypeList, namePath, granteeList, granteeExprList); } @Override protected void validate() { super.validate(); } } public static final ResolvedGrantStmt deserialize( ResolvedGrantStmtProto proto, AbstractDeserializationHelper 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 public ResolvedGrantStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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 { ResolvedRevokeStmt(ResolvedRevokeStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedRevokeStmt( ImmutableList hintList, ImmutableList privilegeList, ImmutableList objectTypeList, ImmutableList namePath, ImmutableList granteeList, ImmutableList granteeExprList) { super( hintList, privilegeList, objectTypeList, namePath, granteeList, granteeExprList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.privilegeList = this.getPrivilegeList(); builder.objectTypeList = this.getObjectTypeList(); builder.namePath = this.getNamePath(); builder.granteeList = this.getGranteeList(); builder.granteeExprList = this.getGranteeExprList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGrantOrRevokeStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setPrivilegeList(List v) { super.setPrivilegeList(v); return this; } @Override @CanIgnoreReturnValue public Builder setObjectTypeList(List v) { super.setObjectTypeList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setGranteeList(List v) { super.setGranteeList(v); return this; } @Override @CanIgnoreReturnValue public Builder setGranteeExprList(List v) { super.setGranteeExprList(v); return this; } @Override public final ResolvedRevokeStmt build() { validate(); return new ResolvedRevokeStmt( hintList, privilegeList, objectTypeList, namePath, granteeList, granteeExprList); } @Override protected void validate() { super.validate(); } } public static final ResolvedRevokeStmt deserialize( ResolvedRevokeStmtProto proto, AbstractDeserializationHelper 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 public ResolvedRevokeStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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 . It * is optional if * FEATURE_ALLOW_MISSING_PATH_EXPRESSION_IN_ALTER_DDL is enabled. * 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; ResolvedAlterObjectStmt(ResolvedAlterObjectStmtProto proto, AbstractDeserializationHelper 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(); } ResolvedAlterObjectStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList); this.namePath = namePath; this.alterActionList = alterActionList; this.isIfExists = isIfExists; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedStatement.Builder { protected ImmutableList namePath = ImmutableList.of(); protected ImmutableList alterActionList = null; protected Boolean isIfExists = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setAlterActionList(List v) { this.alterActionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @Override public abstract ResolvedAlterObjectStmt build(); @Override protected void validate() { super.validate(); Preconditions.checkArgument( alterActionList != null, "alterActionList must be set"); } } public static ResolvedAlterObjectStmt deserialize( AnyResolvedAlterObjectStmtProto proto, AbstractDeserializationHelper 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); case RESOLVED_ALTER_ALL_ROW_ACCESS_POLICIES_STMT_NODE: return ResolvedAlterAllRowAccessPoliciesStmt.deserialize( proto.getResolvedAlterAllRowAccessPoliciesStmtNode(), helper); case RESOLVED_ALTER_ENTITY_STMT_NODE: return ResolvedAlterEntityStmt.deserialize( proto.getResolvedAlterEntityStmtNode(), helper); case RESOLVED_ALTER_SCHEMA_STMT_NODE: return ResolvedAlterSchemaStmt.deserialize( proto.getResolvedAlterSchemaStmtNode(), helper); case RESOLVED_ALTER_PRIVILEGE_RESTRICTION_STMT_NODE: return ResolvedAlterPrivilegeRestrictionStmt.deserialize( proto.getResolvedAlterPrivilegeRestrictionStmtNode(), helper); case RESOLVED_ALTER_MODEL_STMT_NODE: return ResolvedAlterModelStmt.deserialize( proto.getResolvedAlterModelStmtNode(), helper); case RESOLVED_ALTER_APPROX_VIEW_STMT_NODE: return ResolvedAlterApproxViewStmt.deserialize( proto.getResolvedAlterApproxViewStmtNode(), helper); case RESOLVED_ALTER_EXTERNAL_SCHEMA_STMT_NODE: return ResolvedAlterExternalSchemaStmt.deserialize( proto.getResolvedAlterExternalSchemaStmtNode(), helper); case RESOLVED_ALTER_CONNECTION_STMT_NODE: return ResolvedAlterConnectionStmt.deserialize( proto.getResolvedAlterConnectionStmtNode(), 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 public abstract ResolvedAlterObjectStmt accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(alterActionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(namePath)) { 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 { ResolvedAlterDatabaseStmt(ResolvedAlterDatabaseStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterDatabaseStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList, namePath, alterActionList, isIfExists); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override public final ResolvedAlterDatabaseStmt build() { validate(); return new ResolvedAlterDatabaseStmt( hintList, namePath, alterActionList, isIfExists); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterDatabaseStmt deserialize( ResolvedAlterDatabaseStmtProto proto, AbstractDeserializationHelper 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 public ResolvedAlterDatabaseStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: * ALTER MATERIALIZED VIEW [IF EXISTS] */ public static final class ResolvedAlterMaterializedViewStmt extends ResolvedAlterObjectStmt { ResolvedAlterMaterializedViewStmt(ResolvedAlterMaterializedViewStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterMaterializedViewStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList, namePath, alterActionList, isIfExists); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override public final ResolvedAlterMaterializedViewStmt build() { validate(); return new ResolvedAlterMaterializedViewStmt( hintList, namePath, alterActionList, isIfExists); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterMaterializedViewStmt deserialize( ResolvedAlterMaterializedViewStmtProto proto, AbstractDeserializationHelper 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 public ResolvedAlterMaterializedViewStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: * ALTER APPROX VIEW [IF EXISTS] */ public static final class ResolvedAlterApproxViewStmt extends ResolvedAlterObjectStmt { ResolvedAlterApproxViewStmt(ResolvedAlterApproxViewStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterApproxViewStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList, namePath, alterActionList, isIfExists); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override public final ResolvedAlterApproxViewStmt build() { validate(); return new ResolvedAlterApproxViewStmt( hintList, namePath, alterActionList, isIfExists); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterApproxViewStmt deserialize( ResolvedAlterApproxViewStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterApproxViewStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_APPROX_VIEW_STMT; } @Override public final String nodeKindString() { return "AlterApproxViewStmt"; } /** * 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(); ResolvedAlterApproxViewStmtProto.Builder childBuilder = ResolvedAlterApproxViewStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterApproxViewStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterApproxViewStmtProto.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, ResolvedAlterApproxViewStmtProto.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 public ResolvedAlterApproxViewStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: * ALTER SCHEMA [IF NOT EXISTS] ; */ public static final class ResolvedAlterSchemaStmt extends ResolvedAlterObjectStmt { ResolvedAlterSchemaStmt(ResolvedAlterSchemaStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterSchemaStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList, namePath, alterActionList, isIfExists); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override public final ResolvedAlterSchemaStmt build() { validate(); return new ResolvedAlterSchemaStmt( hintList, namePath, alterActionList, isIfExists); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterSchemaStmt deserialize( ResolvedAlterSchemaStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterSchemaStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_SCHEMA_STMT; } @Override public final String nodeKindString() { return "AlterSchemaStmt"; } /** * 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(); ResolvedAlterSchemaStmtProto.Builder childBuilder = ResolvedAlterSchemaStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterSchemaStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterSchemaStmtProto.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, ResolvedAlterSchemaStmtProto.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 public ResolvedAlterSchemaStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: * ALTER EXTERNAL SCHEMA [IF EXISTS] ; */ public static final class ResolvedAlterExternalSchemaStmt extends ResolvedAlterObjectStmt { ResolvedAlterExternalSchemaStmt(ResolvedAlterExternalSchemaStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterExternalSchemaStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList, namePath, alterActionList, isIfExists); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override public final ResolvedAlterExternalSchemaStmt build() { validate(); return new ResolvedAlterExternalSchemaStmt( hintList, namePath, alterActionList, isIfExists); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterExternalSchemaStmt deserialize( ResolvedAlterExternalSchemaStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterExternalSchemaStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_EXTERNAL_SCHEMA_STMT; } @Override public final String nodeKindString() { return "AlterExternalSchemaStmt"; } /** * 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(); ResolvedAlterExternalSchemaStmtProto.Builder childBuilder = ResolvedAlterExternalSchemaStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterExternalSchemaStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterExternalSchemaStmtProto.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, ResolvedAlterExternalSchemaStmtProto.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 public ResolvedAlterExternalSchemaStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: * ALTER MODEL [IF EXISTS] */ public static final class ResolvedAlterModelStmt extends ResolvedAlterObjectStmt { ResolvedAlterModelStmt(ResolvedAlterModelStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterModelStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList, namePath, alterActionList, isIfExists); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override public final ResolvedAlterModelStmt build() { validate(); return new ResolvedAlterModelStmt( hintList, namePath, alterActionList, isIfExists); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterModelStmt deserialize( ResolvedAlterModelStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterModelStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_MODEL_STMT; } @Override public final String nodeKindString() { return "AlterModelStmt"; } /** * 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(); ResolvedAlterModelStmtProto.Builder childBuilder = ResolvedAlterModelStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterModelStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterModelStmtProto.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, ResolvedAlterModelStmtProto.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 public ResolvedAlterModelStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: * ALTER TABLE [IF EXISTS] */ public static final class ResolvedAlterTableStmt extends ResolvedAlterObjectStmt { ResolvedAlterTableStmt(ResolvedAlterTableStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterTableStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList, namePath, alterActionList, isIfExists); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override public final ResolvedAlterTableStmt build() { validate(); return new ResolvedAlterTableStmt( hintList, namePath, alterActionList, isIfExists); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterTableStmt deserialize( ResolvedAlterTableStmtProto proto, AbstractDeserializationHelper 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 public ResolvedAlterTableStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement: * ALTER VIEW [IF EXISTS] */ public static final class ResolvedAlterViewStmt extends ResolvedAlterObjectStmt { ResolvedAlterViewStmt(ResolvedAlterViewStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterViewStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList, namePath, alterActionList, isIfExists); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override public final ResolvedAlterViewStmt build() { validate(); return new ResolvedAlterViewStmt( hintList, namePath, alterActionList, isIfExists); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterViewStmt deserialize( ResolvedAlterViewStmtProto proto, AbstractDeserializationHelper 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 public ResolvedAlterViewStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * A common super class for all actions in statement ALTER */ public static abstract class ResolvedAlterAction extends ResolvedArgument { ResolvedAlterAction(ResolvedAlterActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterAction() { super(); } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedArgument.Builder { private Builder() {} @Override public abstract ResolvedAlterAction build(); @Override protected void validate() { super.validate(); } } public static ResolvedAlterAction deserialize( AnyResolvedAlterActionProto proto, AbstractDeserializationHelper 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); case RESOLVED_SET_AS_ACTION_NODE: return ResolvedSetAsAction.deserialize( proto.getResolvedSetAsActionNode(), helper); case RESOLVED_ADD_CONSTRAINT_ACTION_NODE: return ResolvedAddConstraintAction.deserialize( proto.getResolvedAddConstraintActionNode(), helper); case RESOLVED_DROP_CONSTRAINT_ACTION_NODE: return ResolvedDropConstraintAction.deserialize( proto.getResolvedDropConstraintActionNode(), helper); case RESOLVED_DROP_PRIMARY_KEY_ACTION_NODE: return ResolvedDropPrimaryKeyAction.deserialize( proto.getResolvedDropPrimaryKeyActionNode(), helper); case RESOLVED_RENAME_COLUMN_ACTION_NODE: return ResolvedRenameColumnAction.deserialize( proto.getResolvedRenameColumnActionNode(), helper); case RESOLVED_SET_COLLATE_CLAUSE_NODE: return ResolvedSetCollateClause.deserialize( proto.getResolvedSetCollateClauseNode(), helper); case RESOLVED_RESTRICT_TO_ACTION_NODE: return ResolvedRestrictToAction.deserialize( proto.getResolvedRestrictToActionNode(), helper); case RESOLVED_ADD_TO_RESTRICTEE_LIST_ACTION_NODE: return ResolvedAddToRestricteeListAction.deserialize( proto.getResolvedAddToRestricteeListActionNode(), helper); case RESOLVED_REMOVE_FROM_RESTRICTEE_LIST_ACTION_NODE: return ResolvedRemoveFromRestricteeListAction.deserialize( proto.getResolvedRemoveFromRestricteeListActionNode(), helper); case RESOLVED_ALTER_COLUMN_ACTION_NODE: return ResolvedAlterColumnAction.deserialize( proto.getResolvedAlterColumnActionNode(), helper); case RESOLVED_ALTER_SUB_ENTITY_ACTION_NODE: return ResolvedAlterSubEntityAction.deserialize( proto.getResolvedAlterSubEntityActionNode(), helper); case RESOLVED_ADD_SUB_ENTITY_ACTION_NODE: return ResolvedAddSubEntityAction.deserialize( proto.getResolvedAddSubEntityActionNode(), helper); case RESOLVED_DROP_SUB_ENTITY_ACTION_NODE: return ResolvedDropSubEntityAction.deserialize( proto.getResolvedDropSubEntityActionNode(), 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 public abstract ResolvedAlterAction accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * A super class for all ALTER COLUMN actions in the ALTER TABLE statement: * ALTER TABLE ALTER COLUMN [IF EXISTS] * *

silently ignores the "column does not exist" error. * is the name of the column. */ public static abstract class ResolvedAlterColumnAction extends ResolvedAlterAction { private final boolean isIfExists; private final String column; ResolvedAlterColumnAction(ResolvedAlterColumnActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); column = proto.getColumn(); } ResolvedAlterColumnAction( boolean isIfExists, String column) { super(); this.isIfExists = isIfExists; this.column = column; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedAlterAction.Builder { protected Boolean isIfExists = null; protected String column = null; private Builder() {} @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setColumn(String v) { this.column = v; Preconditions.checkNotNull(v, "column must not be null"); return this; } @Override public abstract ResolvedAlterColumnAction build(); @Override protected void validate() { super.validate(); Preconditions.checkArgument( column != null, "column must be set"); } } public static ResolvedAlterColumnAction deserialize( AnyResolvedAlterColumnActionProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_ALTER_COLUMN_OPTIONS_ACTION_NODE: return ResolvedAlterColumnOptionsAction.deserialize( proto.getResolvedAlterColumnOptionsActionNode(), helper); case RESOLVED_ALTER_COLUMN_DROP_NOT_NULL_ACTION_NODE: return ResolvedAlterColumnDropNotNullAction.deserialize( proto.getResolvedAlterColumnDropNotNullActionNode(), helper); case RESOLVED_ALTER_COLUMN_SET_DATA_TYPE_ACTION_NODE: return ResolvedAlterColumnSetDataTypeAction.deserialize( proto.getResolvedAlterColumnSetDataTypeActionNode(), helper); case RESOLVED_ALTER_COLUMN_SET_DEFAULT_ACTION_NODE: return ResolvedAlterColumnSetDefaultAction.deserialize( proto.getResolvedAlterColumnSetDefaultActionNode(), helper); case RESOLVED_ALTER_COLUMN_DROP_DEFAULT_ACTION_NODE: return ResolvedAlterColumnDropDefaultAction.deserialize( proto.getResolvedAlterColumnDropDefaultActionNode(), helper); case RESOLVED_ALTER_COLUMN_DROP_GENERATED_ACTION_NODE: return ResolvedAlterColumnDropGeneratedAction.deserialize( proto.getResolvedAlterColumnDropGeneratedActionNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedAlterColumnActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedAlterColumnActionProto.Builder builder = ResolvedAlterColumnActionProto.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(); AnyResolvedAlterColumnActionProto.Builder childBuilder = AnyResolvedAlterColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterColumnActionNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedAlterColumnActionProto.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, AnyResolvedAlterColumnActionProto.Builder builder); /** * Serializes this node into the given {@link ResolvedAlterColumnActionProto.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, ResolvedAlterColumnActionProto.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()); // column is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setColumn(this.getColumn()); } public final boolean getIsIfExists() { return isIfExists; } public final String getColumn() { return column; } @Override public abstract ResolvedAlterColumnAction accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(isIfExists)) { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } { fields.add(new DebugStringField("column", DebugStrings.toStringImpl(column))); } } } /** * 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; ResolvedSetOptionsAction(ResolvedSetOptionsActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedSetOptionsAction( ImmutableList optionList) { super(); this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected ImmutableList optionList = null; private Builder() {} @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedSetOptionsAction build() { validate(); return new ResolvedSetOptionsAction( optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( optionList != null, "optionList must be set"); } } public static final ResolvedSetOptionsAction deserialize( ResolvedSetOptionsActionProto proto, AbstractDeserializationHelper 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 public ResolvedSetOptionsAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * Alter sub-entity action for ALTER statement. * (broken link) * *

ALTER [IF EXISTS] * *

engine-specific sub-entity type to be altered. * the identifier for the sub-entity resource being altered. * action for the sub-entity resource, such as * SET OPTIONS or a further nested ALTER sub-entity action. * if set, skip the alter action if the resource does * not exist. */ public static final class ResolvedAlterSubEntityAction extends ResolvedAlterAction { private final String entityType; private final String name; private final ResolvedAlterAction alterAction; private final boolean isIfExists; ResolvedAlterSubEntityAction(ResolvedAlterSubEntityActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); entityType = proto.getEntityType(); name = proto.getName(); if (proto.hasAlterAction()) { alterAction = ResolvedAlterAction.deserialize(proto.getAlterAction(), helper); } else { alterAction = null; } isIfExists = proto.getIsIfExists(); } ResolvedAlterSubEntityAction( String entityType, String name, ResolvedAlterAction alterAction, boolean isIfExists) { super(); this.entityType = entityType; this.name = name; this.alterAction = alterAction; this.isIfExists = isIfExists; } @Override public Builder toBuilder() { Builder builder = builder(); builder.entityType = this.getEntityType(); builder.name = this.getName(); builder.alterAction = this.getAlterAction(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected String entityType = null; protected String name = null; protected ResolvedAlterAction alterAction = null; protected Boolean isIfExists = null; private Builder() {} @CanIgnoreReturnValue public Builder setEntityType(String v) { this.entityType = v; Preconditions.checkNotNull(v, "entityType must not be null"); return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setAlterAction(ResolvedAlterAction v) { this.alterAction = v; Preconditions.checkNotNull(v, "alterAction must not be null"); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @Override public final ResolvedAlterSubEntityAction build() { validate(); return new ResolvedAlterSubEntityAction( entityType, name, alterAction, isIfExists); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( entityType != null, "entityType must be set"); Preconditions.checkArgument( name != null, "name must be set"); Preconditions.checkArgument( alterAction != null, "alterAction must be set"); } } public static final ResolvedAlterSubEntityAction deserialize( ResolvedAlterSubEntityActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterSubEntityAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_SUB_ENTITY_ACTION; } @Override public final String nodeKindString() { return "AlterSubEntityAction"; } /** * 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(); ResolvedAlterSubEntityActionProto.Builder childBuilder = ResolvedAlterSubEntityActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterSubEntityActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterSubEntityActionProto.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, ResolvedAlterSubEntityActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // entityType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEntityType(this.getEntityType()); // 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()); // alterAction is an AST node. Call its serialization chain. if (this.getAlterAction() != null) { AnyResolvedAlterActionProto.Builder alterActionBuilder = AnyResolvedAlterActionProto.newBuilder(); this.getAlterAction().serialize( fileDescriptorSetsBuilder, alterActionBuilder); proto.setAlterAction( alterActionBuilder.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 String getEntityType() { return entityType; } public final String getName() { return name; } public final ResolvedAlterAction getAlterAction() { return alterAction; } public final boolean getIsIfExists() { return isIfExists; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAlterSubEntityAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(alterAction); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("entity_type", DebugStrings.toStringImpl(entityType))); } { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (alterAction != null) { fields.add(new DebugStringField("alter_action", alterAction)); } if (!DebugStrings.isDefaultValue(isIfExists)) { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } } } /** * Add sub-entity action for ALTER statement. * (broken link) * *

ADD [IF NOT EXISTS] [OPTIONS(...)] * *

engine-specific sub-entity type to be added. * the identifier for the sub-entity resource being added. * engine specific options_list for the sub-entity resource. * if set, skip the add action if the resource * already exists. */ public static final class ResolvedAddSubEntityAction extends ResolvedAlterAction { private final String entityType; private final String name; private final ImmutableList optionsList; private final boolean isIfNotExists; ResolvedAddSubEntityAction(ResolvedAddSubEntityActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); entityType = proto.getEntityType(); name = proto.getName(); ImmutableList.Builder optionsListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionsListList()) { optionsListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionsList = optionsListBuilder.build(); isIfNotExists = proto.getIsIfNotExists(); } ResolvedAddSubEntityAction( String entityType, String name, ImmutableList optionsList, boolean isIfNotExists) { super(); this.entityType = entityType; this.name = name; this.optionsList = optionsList; this.isIfNotExists = isIfNotExists; } @Override public Builder toBuilder() { Builder builder = builder(); builder.entityType = this.getEntityType(); builder.name = this.getName(); builder.optionsList = this.getOptionsList(); builder.isIfNotExists = this.getIsIfNotExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected String entityType = null; protected String name = null; protected ImmutableList optionsList = null; protected Boolean isIfNotExists = null; private Builder() {} @CanIgnoreReturnValue public Builder setEntityType(String v) { this.entityType = v; Preconditions.checkNotNull(v, "entityType must not be null"); return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setOptionsList(List v) { this.optionsList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIsIfNotExists(boolean v) { this.isIfNotExists = v; return this; } @Override public final ResolvedAddSubEntityAction build() { validate(); return new ResolvedAddSubEntityAction( entityType, name, optionsList, isIfNotExists); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( entityType != null, "entityType must be set"); Preconditions.checkArgument( name != null, "name must be set"); Preconditions.checkArgument( optionsList != null, "optionsList must be set"); } } public static final ResolvedAddSubEntityAction deserialize( ResolvedAddSubEntityActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAddSubEntityAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ADD_SUB_ENTITY_ACTION; } @Override public final String nodeKindString() { return "AddSubEntityAction"; } /** * 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(); ResolvedAddSubEntityActionProto.Builder childBuilder = ResolvedAddSubEntityActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAddSubEntityActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAddSubEntityActionProto.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, ResolvedAddSubEntityActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // entityType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEntityType(this.getEntityType()); // 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()); // optionsList is a collection of AST nodes. Serialize each of them. ImmutableList optionsLists = this.getOptionsList(); for (ResolvedOption element : optionsLists) { ResolvedOptionProto.Builder optionsListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, optionsListBuilder); proto.addOptionsList(optionsListBuilder.build()); } // 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()); } public final String getEntityType() { return entityType; } public final String getName() { return name; } public final ImmutableList getOptionsList() { return optionsList; } public final boolean getIsIfNotExists() { return isIfNotExists; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAddSubEntityAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionsList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("entity_type", DebugStrings.toStringImpl(entityType))); } { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (!optionsList.isEmpty()) { fields.add(new DebugStringField("options_list", optionsList)); } if (!DebugStrings.isDefaultValue(isIfNotExists)) { fields.add(new DebugStringField("is_if_not_exists", DebugStrings.toStringImpl(isIfNotExists))); } } } /** * Drop sub-entity action for ALTER statement. * (broken link) * *

DROP [IF EXISTS] * *

engine-specific sub-entity type to be dropped. * the identifier for the sub-entity resource being dropped. * if set, skip the drop action if the resource does * not exist. */ public static final class ResolvedDropSubEntityAction extends ResolvedAlterAction { private final String entityType; private final String name; private final boolean isIfExists; ResolvedDropSubEntityAction(ResolvedDropSubEntityActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); entityType = proto.getEntityType(); name = proto.getName(); isIfExists = proto.getIsIfExists(); } ResolvedDropSubEntityAction( String entityType, String name, boolean isIfExists) { super(); this.entityType = entityType; this.name = name; this.isIfExists = isIfExists; } @Override public Builder toBuilder() { Builder builder = builder(); builder.entityType = this.getEntityType(); builder.name = this.getName(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected String entityType = null; protected String name = null; protected Boolean isIfExists = null; private Builder() {} @CanIgnoreReturnValue public Builder setEntityType(String v) { this.entityType = v; Preconditions.checkNotNull(v, "entityType must not be null"); return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @Override public final ResolvedDropSubEntityAction build() { validate(); return new ResolvedDropSubEntityAction( entityType, name, isIfExists); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( entityType != null, "entityType must be set"); Preconditions.checkArgument( name != null, "name must be set"); } } public static final ResolvedDropSubEntityAction deserialize( ResolvedDropSubEntityActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedDropSubEntityAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_SUB_ENTITY_ACTION; } @Override public final String nodeKindString() { return "DropSubEntityAction"; } /** * 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(); ResolvedDropSubEntityActionProto.Builder childBuilder = ResolvedDropSubEntityActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropSubEntityActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropSubEntityActionProto.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, ResolvedDropSubEntityActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // entityType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEntityType(this.getEntityType()); // 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()); // 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 String getEntityType() { return entityType; } public final String getName() { return name; } public final boolean getIsIfExists() { return isIfExists; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDropSubEntityAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("entity_type", DebugStrings.toStringImpl(entityType))); } { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (!DebugStrings.isDefaultValue(isIfExists)) { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } } } /** * ADD COLUMN action for ALTER TABLE statement */ public static final class ResolvedAddColumnAction extends ResolvedAlterAction { private final boolean isIfNotExists; private final ResolvedColumnDefinition columnDefinition; ResolvedAddColumnAction(ResolvedAddColumnActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfNotExists = proto.getIsIfNotExists(); if (proto.hasColumnDefinition()) { columnDefinition = ResolvedColumnDefinition.deserialize(proto.getColumnDefinition(), helper); } else { columnDefinition = null; } } ResolvedAddColumnAction( boolean isIfNotExists, ResolvedColumnDefinition columnDefinition) { super(); this.isIfNotExists = isIfNotExists; this.columnDefinition = columnDefinition; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfNotExists = this.getIsIfNotExists(); builder.columnDefinition = this.getColumnDefinition(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected Boolean isIfNotExists = null; protected ResolvedColumnDefinition columnDefinition = null; private Builder() {} @CanIgnoreReturnValue public Builder setIsIfNotExists(boolean v) { this.isIfNotExists = v; return this; } @CanIgnoreReturnValue public Builder setColumnDefinition(ResolvedColumnDefinition v) { this.columnDefinition = v; Preconditions.checkNotNull(v, "columnDefinition must not be null"); return this; } @Override public final ResolvedAddColumnAction build() { validate(); return new ResolvedAddColumnAction( isIfNotExists, columnDefinition); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfNotExists != null, "isIfNotExists must be set"); Preconditions.checkArgument( columnDefinition != null, "columnDefinition must be set"); } } public static final ResolvedAddColumnAction deserialize( ResolvedAddColumnActionProto proto, AbstractDeserializationHelper 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 public ResolvedAddColumnAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnDefinition); } public 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)); } } } /** * ADD CONSTRAINT for ALTER TABLE statement */ public static final class ResolvedAddConstraintAction extends ResolvedAlterAction { private final boolean isIfNotExists; private final ResolvedConstraint constraint; private final Table table; ResolvedAddConstraintAction(ResolvedAddConstraintActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfNotExists = proto.getIsIfNotExists(); if (proto.hasConstraint()) { constraint = ResolvedConstraint.deserialize(proto.getConstraint(), helper); } else { constraint = null; } table = helper.deserialize(proto.getTable()); } ResolvedAddConstraintAction( boolean isIfNotExists, ResolvedConstraint constraint, Table table) { super(); this.isIfNotExists = isIfNotExists; this.constraint = constraint; this.table = table; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfNotExists = this.getIsIfNotExists(); builder.constraint = this.getConstraint(); builder.table = this.getTable(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected Boolean isIfNotExists = null; protected ResolvedConstraint constraint = null; protected Table table = null; private Builder() {} @CanIgnoreReturnValue public Builder setIsIfNotExists(boolean v) { this.isIfNotExists = v; return this; } @CanIgnoreReturnValue public Builder setConstraint(ResolvedConstraint v) { this.constraint = v; Preconditions.checkNotNull(v, "constraint must not be null"); return this; } @CanIgnoreReturnValue public Builder setTable(Table v) { this.table = v; return this; } @Override public final ResolvedAddConstraintAction build() { validate(); return new ResolvedAddConstraintAction( isIfNotExists, constraint, table); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfNotExists != null, "isIfNotExists must be set"); Preconditions.checkArgument( constraint != null, "constraint must be set"); } } public static final ResolvedAddConstraintAction deserialize( ResolvedAddConstraintActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAddConstraintAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ADD_CONSTRAINT_ACTION; } @Override public final String nodeKindString() { return "AddConstraintAction"; } /** * 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(); ResolvedAddConstraintActionProto.Builder childBuilder = ResolvedAddConstraintActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAddConstraintActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAddConstraintActionProto.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, ResolvedAddConstraintActionProto.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()); // constraint is an AST node. Call its serialization chain. if (this.getConstraint() != null) { AnyResolvedConstraintProto.Builder constraintBuilder = AnyResolvedConstraintProto.newBuilder(); this.getConstraint().serialize( fileDescriptorSetsBuilder, constraintBuilder); proto.setConstraint( constraintBuilder.build()); } // 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)); } } public final boolean getIsIfNotExists() { return isIfNotExists; } public final ResolvedConstraint getConstraint() { return constraint; } public final Table getTable() { return table; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAddConstraintAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(constraint); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("is_if_not_exists", DebugStrings.toStringImpl(isIfNotExists))); } if (constraint != null) { fields.add(new DebugStringField("constraint", constraint)); } if (!DebugStrings.isDefaultValue(table)) { fields.add(new DebugStringField("table", DebugStrings.toStringImpl(table))); } } } /** * DROP CONSTRAINT for ALTER TABLE statement */ public static final class ResolvedDropConstraintAction extends ResolvedAlterAction { private final boolean isIfExists; private final String name; ResolvedDropConstraintAction(ResolvedDropConstraintActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); name = proto.getName(); } ResolvedDropConstraintAction( boolean isIfExists, String name) { super(); this.isIfExists = isIfExists; this.name = name; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.name = this.getName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected Boolean isIfExists = null; protected String name = null; private Builder() {} @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @Override public final ResolvedDropConstraintAction build() { validate(); return new ResolvedDropConstraintAction( isIfExists, name); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfExists != null, "isIfExists must be set"); Preconditions.checkArgument( name != null, "name must be set"); } } public static final ResolvedDropConstraintAction deserialize( ResolvedDropConstraintActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedDropConstraintAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_CONSTRAINT_ACTION; } @Override public final String nodeKindString() { return "DropConstraintAction"; } /** * 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(); ResolvedDropConstraintActionProto.Builder childBuilder = ResolvedDropConstraintActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropConstraintActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropConstraintActionProto.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, ResolvedDropConstraintActionProto.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()); } public final boolean getIsIfExists() { return isIfExists; } public final String getName() { return name; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDropConstraintAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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))); } } } /** * DROP PRIMARY KEY [IF EXISTS] for ALTER TABLE statement */ public static final class ResolvedDropPrimaryKeyAction extends ResolvedAlterAction { private final boolean isIfExists; ResolvedDropPrimaryKeyAction(ResolvedDropPrimaryKeyActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); } ResolvedDropPrimaryKeyAction( boolean isIfExists) { super(); this.isIfExists = isIfExists; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected Boolean isIfExists = null; private Builder() {} @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @Override public final ResolvedDropPrimaryKeyAction build() { validate(); return new ResolvedDropPrimaryKeyAction( isIfExists); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfExists != null, "isIfExists must be set"); } } public static final ResolvedDropPrimaryKeyAction deserialize( ResolvedDropPrimaryKeyActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedDropPrimaryKeyAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_PRIMARY_KEY_ACTION; } @Override public final String nodeKindString() { return "DropPrimaryKeyAction"; } /** * 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(); ResolvedDropPrimaryKeyActionProto.Builder childBuilder = ResolvedDropPrimaryKeyActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropPrimaryKeyActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropPrimaryKeyActionProto.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, ResolvedDropPrimaryKeyActionProto.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()); } public final boolean getIsIfExists() { return isIfExists; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDropPrimaryKeyAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } } } /** * This ALTER action: * ALTER COLUMN [IF EXISTS] SET OPTIONS * *

has engine-specific directives that specify how to * alter the metadata for a column. */ public static final class ResolvedAlterColumnOptionsAction extends ResolvedAlterColumnAction { private final ImmutableList optionList; ResolvedAlterColumnOptionsAction(ResolvedAlterColumnOptionsActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedAlterColumnOptionsAction( boolean isIfExists, String column, ImmutableList optionList) { super( isIfExists, column); this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.column = this.getColumn(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterColumnAction.Builder { protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumn(String v) { super.setColumn(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedAlterColumnOptionsAction build() { validate(); return new ResolvedAlterColumnOptionsAction( isIfExists, column, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( optionList != null, "optionList must be set"); } } public static final ResolvedAlterColumnOptionsAction deserialize( ResolvedAlterColumnOptionsActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterColumnOptionsAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_COLUMN_OPTIONS_ACTION; } @Override public final String nodeKindString() { return "AlterColumnOptionsAction"; } /** * Serializes this node into a {@link AnyResolvedAlterColumnActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterColumnActionProto.Builder builder = AnyResolvedAlterColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterColumnActionProto.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, AnyResolvedAlterColumnActionProto.Builder builder) { builder.clear(); ResolvedAlterColumnOptionsActionProto.Builder childBuilder = ResolvedAlterColumnOptionsActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterColumnOptionsActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterColumnOptionsActionProto.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, ResolvedAlterColumnOptionsActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterColumnActionProto parent = (ResolvedAlterColumnActionProto) 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 public ResolvedAlterColumnOptionsAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This ALTER action: * ALTER COLUMN [IF EXISTS] DROP NOT NULL * *

Removes the NOT NULL constraint from the given column. */ public static final class ResolvedAlterColumnDropNotNullAction extends ResolvedAlterColumnAction { ResolvedAlterColumnDropNotNullAction(ResolvedAlterColumnDropNotNullActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterColumnDropNotNullAction( boolean isIfExists, String column) { super( isIfExists, column); } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.column = this.getColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterColumnAction.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumn(String v) { super.setColumn(v); return this; } @Override public final ResolvedAlterColumnDropNotNullAction build() { validate(); return new ResolvedAlterColumnDropNotNullAction( isIfExists, column); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterColumnDropNotNullAction deserialize( ResolvedAlterColumnDropNotNullActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterColumnDropNotNullAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_COLUMN_DROP_NOT_NULL_ACTION; } @Override public final String nodeKindString() { return "AlterColumnDropNotNullAction"; } /** * Serializes this node into a {@link AnyResolvedAlterColumnActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterColumnActionProto.Builder builder = AnyResolvedAlterColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterColumnActionProto.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, AnyResolvedAlterColumnActionProto.Builder builder) { builder.clear(); ResolvedAlterColumnDropNotNullActionProto.Builder childBuilder = ResolvedAlterColumnDropNotNullActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterColumnDropNotNullActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterColumnDropNotNullActionProto.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, ResolvedAlterColumnDropNotNullActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterColumnActionProto parent = (ResolvedAlterColumnActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAlterColumnDropNotNullAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This ALTER action: * ALTER COLUMN [IF EXISTS] DROP GENERATED * *

Removes the generated value (either an expression or identity column) * from the given column. */ public static final class ResolvedAlterColumnDropGeneratedAction extends ResolvedAlterColumnAction { ResolvedAlterColumnDropGeneratedAction(ResolvedAlterColumnDropGeneratedActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterColumnDropGeneratedAction( boolean isIfExists, String column) { super( isIfExists, column); } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.column = this.getColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterColumnAction.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumn(String v) { super.setColumn(v); return this; } @Override public final ResolvedAlterColumnDropGeneratedAction build() { validate(); return new ResolvedAlterColumnDropGeneratedAction( isIfExists, column); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterColumnDropGeneratedAction deserialize( ResolvedAlterColumnDropGeneratedActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterColumnDropGeneratedAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_COLUMN_DROP_GENERATED_ACTION; } @Override public final String nodeKindString() { return "AlterColumnDropGeneratedAction"; } /** * Serializes this node into a {@link AnyResolvedAlterColumnActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterColumnActionProto.Builder builder = AnyResolvedAlterColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterColumnActionProto.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, AnyResolvedAlterColumnActionProto.Builder builder) { builder.clear(); ResolvedAlterColumnDropGeneratedActionProto.Builder childBuilder = ResolvedAlterColumnDropGeneratedActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterColumnDropGeneratedActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterColumnDropGeneratedActionProto.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, ResolvedAlterColumnDropGeneratedActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterColumnActionProto parent = (ResolvedAlterColumnActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAlterColumnDropGeneratedAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * ALTER COLUMN SET DATA TYPE action for ALTER TABLE * statement. It supports updating the data type of the column as * well as updating type parameters and collation specifications of * the column (and on struct fields and array elements). */ public static final class ResolvedAlterColumnSetDataTypeAction extends ResolvedAlterColumnAction { /** * The new type for the column. */ private final Type updatedType; /** * The new type parameters for the column, if the new type has * parameters. Note that unlike with CREATE TABLE, the child_list is * populated for ARRAY and STRUCT types. * TODO Use updated_annotations to pass type parameters. */ private final TypeParameters updatedTypeParameters; /** * The new annotations for the column including the new collation * specifications. Changing options using SET DATA TYPE action is not * allowed. */ private final ResolvedColumnAnnotations updatedAnnotations; ResolvedAlterColumnSetDataTypeAction(ResolvedAlterColumnSetDataTypeActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); updatedType = helper.deserialize(proto.getUpdatedType()); updatedTypeParameters = helper.deserialize(proto.getUpdatedTypeParameters()); if (proto.hasUpdatedAnnotations()) { updatedAnnotations = ResolvedColumnAnnotations.deserialize(proto.getUpdatedAnnotations(), helper); } else { updatedAnnotations = null; } } ResolvedAlterColumnSetDataTypeAction( boolean isIfExists, String column, Type updatedType, TypeParameters updatedTypeParameters, ResolvedColumnAnnotations updatedAnnotations) { super( isIfExists, column); this.updatedType = updatedType; this.updatedTypeParameters = updatedTypeParameters; this.updatedAnnotations = updatedAnnotations; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.column = this.getColumn(); builder.updatedType = this.getUpdatedType(); builder.updatedTypeParameters = this.getUpdatedTypeParameters(); builder.updatedAnnotations = this.getUpdatedAnnotations(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterColumnAction.Builder { protected Type updatedType = null; protected TypeParameters updatedTypeParameters = null; protected ResolvedColumnAnnotations updatedAnnotations = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumn(String v) { super.setColumn(v); return this; } /** * The new type for the column. */ @CanIgnoreReturnValue public Builder setUpdatedType(Type v) { this.updatedType = v; Preconditions.checkNotNull(v, "updatedType must not be null"); return this; } /** * The new type parameters for the column, if the new type has * parameters. Note that unlike with CREATE TABLE, the child_list is * populated for ARRAY and STRUCT types. * TODO Use updated_annotations to pass type parameters. */ @CanIgnoreReturnValue public Builder setUpdatedTypeParameters(TypeParameters v) { this.updatedTypeParameters = v; return this; } /** * The new annotations for the column including the new collation * specifications. Changing options using SET DATA TYPE action is not * allowed. */ @CanIgnoreReturnValue public Builder setUpdatedAnnotations(ResolvedColumnAnnotations v) { this.updatedAnnotations = v; return this; } @Override public final ResolvedAlterColumnSetDataTypeAction build() { validate(); return new ResolvedAlterColumnSetDataTypeAction( isIfExists, column, updatedType, updatedTypeParameters, updatedAnnotations); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( updatedType != null, "updatedType must be set"); } } public static final ResolvedAlterColumnSetDataTypeAction deserialize( ResolvedAlterColumnSetDataTypeActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterColumnSetDataTypeAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_COLUMN_SET_DATA_TYPE_ACTION; } @Override public final String nodeKindString() { return "AlterColumnSetDataTypeAction"; } /** * Serializes this node into a {@link AnyResolvedAlterColumnActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterColumnActionProto.Builder builder = AnyResolvedAlterColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterColumnActionProto.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, AnyResolvedAlterColumnActionProto.Builder builder) { builder.clear(); ResolvedAlterColumnSetDataTypeActionProto.Builder childBuilder = ResolvedAlterColumnSetDataTypeActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterColumnSetDataTypeActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterColumnSetDataTypeActionProto.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, ResolvedAlterColumnSetDataTypeActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterColumnActionProto parent = (ResolvedAlterColumnActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // updatedType is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getUpdatedType() != null) { proto.setUpdatedType( ResolvedNodes.serialize(this.getUpdatedType(), fileDescriptorSetsBuilder)); } // updatedTypeParameters is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getUpdatedTypeParameters() != null) { proto.setUpdatedTypeParameters( ResolvedNodes.serialize(this.getUpdatedTypeParameters(), fileDescriptorSetsBuilder)); } // updatedAnnotations is an AST node. Call its serialization chain. if (this.getUpdatedAnnotations() != null) { ResolvedColumnAnnotationsProto.Builder updatedAnnotationsBuilder = ResolvedColumnAnnotationsProto.newBuilder(); this.getUpdatedAnnotations().serialize( fileDescriptorSetsBuilder, updatedAnnotationsBuilder); proto.setUpdatedAnnotations( updatedAnnotationsBuilder.build()); } } /** * The new type for the column. */ public final Type getUpdatedType() { return updatedType; } /** * The new type parameters for the column, if the new type has * parameters. Note that unlike with CREATE TABLE, the child_list is * populated for ARRAY and STRUCT types. * TODO Use updated_annotations to pass type parameters. */ public final TypeParameters getUpdatedTypeParameters() { return updatedTypeParameters; } /** * The new annotations for the column including the new collation * specifications. Changing options using SET DATA TYPE action is not * allowed. */ public final ResolvedColumnAnnotations getUpdatedAnnotations() { return updatedAnnotations; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAlterColumnSetDataTypeAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(updatedAnnotations); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("updated_type", DebugStrings.toStringImpl(updatedType))); } if (!DebugStrings.isDefaultValue(updatedTypeParameters)) { fields.add(new DebugStringField("updated_type_parameters", DebugStrings.toStringImpl(updatedTypeParameters))); } if (updatedAnnotations != null) { fields.add(new DebugStringField("updated_annotations", updatedAnnotations)); } } } /** * Alter column set default action: * ALTER COLUMN [IF EXISTS] SET DEFAULT * *

sets the new default value expression. It only impacts * future inserted rows, and has no impact on existing rows with the current * default value. This is a metadata only operation. * *

Resolver validates that expression can be coerced to the * column type when exists. If is not found and * is true, Resolver skips type match check. */ public static final class ResolvedAlterColumnSetDefaultAction extends ResolvedAlterColumnAction { private final ResolvedColumnDefaultValue defaultValue; ResolvedAlterColumnSetDefaultAction(ResolvedAlterColumnSetDefaultActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasDefaultValue()) { defaultValue = ResolvedColumnDefaultValue.deserialize(proto.getDefaultValue(), helper); } else { defaultValue = null; } } ResolvedAlterColumnSetDefaultAction( boolean isIfExists, String column, ResolvedColumnDefaultValue defaultValue) { super( isIfExists, column); this.defaultValue = defaultValue; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.column = this.getColumn(); builder.defaultValue = this.getDefaultValue(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterColumnAction.Builder { protected ResolvedColumnDefaultValue defaultValue = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumn(String v) { super.setColumn(v); return this; } @CanIgnoreReturnValue public Builder setDefaultValue(ResolvedColumnDefaultValue v) { this.defaultValue = v; Preconditions.checkNotNull(v, "defaultValue must not be null"); return this; } @Override public final ResolvedAlterColumnSetDefaultAction build() { validate(); return new ResolvedAlterColumnSetDefaultAction( isIfExists, column, defaultValue); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( defaultValue != null, "defaultValue must be set"); } } public static final ResolvedAlterColumnSetDefaultAction deserialize( ResolvedAlterColumnSetDefaultActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterColumnSetDefaultAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_COLUMN_SET_DEFAULT_ACTION; } @Override public final String nodeKindString() { return "AlterColumnSetDefaultAction"; } /** * Serializes this node into a {@link AnyResolvedAlterColumnActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterColumnActionProto.Builder builder = AnyResolvedAlterColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterColumnActionProto.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, AnyResolvedAlterColumnActionProto.Builder builder) { builder.clear(); ResolvedAlterColumnSetDefaultActionProto.Builder childBuilder = ResolvedAlterColumnSetDefaultActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterColumnSetDefaultActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterColumnSetDefaultActionProto.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, ResolvedAlterColumnSetDefaultActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterColumnActionProto parent = (ResolvedAlterColumnActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // defaultValue is an AST node. Call its serialization chain. if (this.getDefaultValue() != null) { ResolvedColumnDefaultValueProto.Builder defaultValueBuilder = ResolvedColumnDefaultValueProto.newBuilder(); this.getDefaultValue().serialize( fileDescriptorSetsBuilder, defaultValueBuilder); proto.setDefaultValue( defaultValueBuilder.build()); } } public final ResolvedColumnDefaultValue getDefaultValue() { return defaultValue; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAlterColumnSetDefaultAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(defaultValue); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (defaultValue != null) { fields.add(new DebugStringField("default_value", defaultValue)); } } } /** * This ALTER action: * ALTER COLUMN [IF EXISTS] DROP DEFAULT * *

Removes the DEFAULT constraint from the given column. */ public static final class ResolvedAlterColumnDropDefaultAction extends ResolvedAlterColumnAction { ResolvedAlterColumnDropDefaultAction(ResolvedAlterColumnDropDefaultActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterColumnDropDefaultAction( boolean isIfExists, String column) { super( isIfExists, column); } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.column = this.getColumn(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterColumnAction.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumn(String v) { super.setColumn(v); return this; } @Override public final ResolvedAlterColumnDropDefaultAction build() { validate(); return new ResolvedAlterColumnDropDefaultAction( isIfExists, column); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterColumnDropDefaultAction deserialize( ResolvedAlterColumnDropDefaultActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterColumnDropDefaultAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_COLUMN_DROP_DEFAULT_ACTION; } @Override public final String nodeKindString() { return "AlterColumnDropDefaultAction"; } /** * Serializes this node into a {@link AnyResolvedAlterColumnActionProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedAlterColumnActionProto.Builder builder = AnyResolvedAlterColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedAlterColumnActionProto.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, AnyResolvedAlterColumnActionProto.Builder builder) { builder.clear(); ResolvedAlterColumnDropDefaultActionProto.Builder childBuilder = ResolvedAlterColumnDropDefaultActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterColumnDropDefaultActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterColumnDropDefaultActionProto.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, ResolvedAlterColumnDropDefaultActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterColumnActionProto parent = (ResolvedAlterColumnActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAlterColumnDropDefaultAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * DROP COLUMN action for ALTER TABLE statement * *

is the name of the column to drop. */ public static final class ResolvedDropColumnAction extends ResolvedAlterAction { private final boolean isIfExists; private final String name; ResolvedDropColumnAction(ResolvedDropColumnActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); name = proto.getName(); } ResolvedDropColumnAction( boolean isIfExists, String name) { super(); this.isIfExists = isIfExists; this.name = name; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.name = this.getName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected Boolean isIfExists = null; protected String name = null; private Builder() {} @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @Override public final ResolvedDropColumnAction build() { validate(); return new ResolvedDropColumnAction( isIfExists, name); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfExists != null, "isIfExists must be set"); Preconditions.checkArgument( name != null, "name must be set"); } } public static final ResolvedDropColumnAction deserialize( ResolvedDropColumnActionProto proto, AbstractDeserializationHelper 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()); } public final boolean getIsIfExists() { return isIfExists; } public final String getName() { return name; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDropColumnAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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))); } } } /** * RENAME COLUMN action for ALTER TABLE statement. * *

is the name of the column to rename. * is the new name of the column. * *

RENAME COLUMN actions cannot be part of the same alter_action_list as any * other type of action. * Chains of RENAME COLUMN will be interpreted as a sequence of mutations. * The order of actions matters. Each refers to a column name that * exists after all preceding renames have been applied. */ public static final class ResolvedRenameColumnAction extends ResolvedAlterAction { private final boolean isIfExists; private final String name; private final String newName; ResolvedRenameColumnAction(ResolvedRenameColumnActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); name = proto.getName(); newName = proto.getNewName(); } ResolvedRenameColumnAction( boolean isIfExists, String name, String newName) { super(); this.isIfExists = isIfExists; this.name = name; this.newName = newName; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.name = this.getName(); builder.newName = this.getNewName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected Boolean isIfExists = null; protected String name = null; protected String newName = null; private Builder() {} @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setNewName(String v) { this.newName = v; Preconditions.checkNotNull(v, "newName must not be null"); return this; } @Override public final ResolvedRenameColumnAction build() { validate(); return new ResolvedRenameColumnAction( isIfExists, name, newName); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); Preconditions.checkArgument( newName != null, "newName must be set"); } } public static final ResolvedRenameColumnAction deserialize( ResolvedRenameColumnActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedRenameColumnAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RENAME_COLUMN_ACTION; } @Override public final String nodeKindString() { return "RenameColumnAction"; } /** * 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(); ResolvedRenameColumnActionProto.Builder childBuilder = ResolvedRenameColumnActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRenameColumnActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRenameColumnActionProto.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, ResolvedRenameColumnActionProto.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()); // 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 boolean getIsIfExists() { return isIfExists; } public final String getName() { return name; } public final String getNewName() { return newName; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedRenameColumnAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(isIfExists)) { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } { fields.add(new DebugStringField("new_name", DebugStrings.toStringImpl(newName))); } } } /** * SET AS action for generic ALTER statement. * Exactly one of , should be non-empty. * *

is a JSON literal to be interpreted by engine. * is a text literal to be interpreted by engine. */ public static final class ResolvedSetAsAction extends ResolvedAlterAction { private final String entityBodyJson; private final String entityBodyText; ResolvedSetAsAction(ResolvedSetAsActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); entityBodyJson = proto.getEntityBodyJson(); entityBodyText = proto.getEntityBodyText(); } ResolvedSetAsAction( String entityBodyJson, String entityBodyText) { super(); this.entityBodyJson = entityBodyJson; this.entityBodyText = entityBodyText; } @Override public Builder toBuilder() { Builder builder = builder(); builder.entityBodyJson = this.getEntityBodyJson(); builder.entityBodyText = this.getEntityBodyText(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected String entityBodyJson = null; protected String entityBodyText = null; private Builder() {} @CanIgnoreReturnValue public Builder setEntityBodyJson(String v) { this.entityBodyJson = v; return this; } @CanIgnoreReturnValue public Builder setEntityBodyText(String v) { this.entityBodyText = v; return this; } @Override public final ResolvedSetAsAction build() { validate(); return new ResolvedSetAsAction( entityBodyJson, entityBodyText); } @Override protected void validate() { super.validate(); } } public static final ResolvedSetAsAction deserialize( ResolvedSetAsActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedSetAsAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SET_AS_ACTION; } @Override public final String nodeKindString() { return "SetAsAction"; } /** * 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(); ResolvedSetAsActionProto.Builder childBuilder = ResolvedSetAsActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSetAsActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSetAsActionProto.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, ResolvedSetAsActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // entityBodyJson is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEntityBodyJson(this.getEntityBodyJson()); // entityBodyText is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEntityBodyText(this.getEntityBodyText()); } public final String getEntityBodyJson() { return entityBodyJson; } public final String getEntityBodyText() { return entityBodyText; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedSetAsAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(entityBodyJson)) { fields.add(new DebugStringField("entity_body_json", DebugStrings.toStringImpl(entityBodyJson))); } if (!DebugStrings.isDefaultValue(entityBodyText)) { fields.add(new DebugStringField("entity_body_text", DebugStrings.toStringImpl(entityBodyText))); } } } /** * SET DEFAULT COLLATE clause for generic ALTER statement. * *

specifies the new default collation specification for a * table or schema. Modifying the default collation for a table or schema * does not affect any existing columns or tables - the new default * collation only affects new tables and/or columns if applicable. Only * string literals are allowed for this field. */ public static final class ResolvedSetCollateClause extends ResolvedAlterAction { private final ResolvedExpr collationName; ResolvedSetCollateClause(ResolvedSetCollateClauseProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasCollationName()) { collationName = ResolvedExpr.deserialize(proto.getCollationName(), helper); } else { collationName = null; } } ResolvedSetCollateClause( ResolvedExpr collationName) { super(); this.collationName = collationName; } @Override public Builder toBuilder() { Builder builder = builder(); builder.collationName = this.getCollationName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected ResolvedExpr collationName = null; private Builder() {} @CanIgnoreReturnValue public Builder setCollationName(ResolvedExpr v) { this.collationName = v; Preconditions.checkNotNull(v, "collationName must not be null"); return this; } @Override public final ResolvedSetCollateClause build() { validate(); return new ResolvedSetCollateClause( collationName); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( collationName != null, "collationName must be set"); } } public static final ResolvedSetCollateClause deserialize( ResolvedSetCollateClauseProto proto, AbstractDeserializationHelper helper) { return new ResolvedSetCollateClause(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SET_COLLATE_CLAUSE; } @Override public final String nodeKindString() { return "SetCollateClause"; } /** * 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(); ResolvedSetCollateClauseProto.Builder childBuilder = ResolvedSetCollateClauseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSetCollateClauseNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSetCollateClauseProto.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, ResolvedSetCollateClauseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // 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()); } } public final ResolvedExpr getCollationName() { return collationName; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedSetCollateClause accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(collationName); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (collationName != null) { fields.add(new DebugStringField("collation_name", collationName)); } } } /** * 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; ResolvedAlterTableSetOptionsStmt(ResolvedAlterTableSetOptionsStmtProto proto, AbstractDeserializationHelper 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(); } ResolvedAlterTableSetOptionsStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList optionList, boolean isIfExists) { super( hintList); this.namePath = namePath; this.optionList = optionList; this.isIfExists = isIfExists; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.optionList = this.getOptionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ImmutableList namePath = null; protected ImmutableList optionList = null; protected Boolean isIfExists = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @Override public final ResolvedAlterTableSetOptionsStmt build() { validate(); return new ResolvedAlterTableSetOptionsStmt( hintList, namePath, optionList, isIfExists); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( namePath != null, "namePath must be set"); Preconditions.checkArgument( optionList != null, "optionList must be set"); } } public static final ResolvedAlterTableSetOptionsStmt deserialize( ResolvedAlterTableSetOptionsStmtProto proto, AbstractDeserializationHelper 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 public ResolvedAlterTableSetOptionsStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public 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; ResolvedRenameStmt(ResolvedRenameStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); objectType = proto.getObjectType(); oldNamePath = ImmutableList.copyOf(proto.getOldNamePathList()); newNamePath = ImmutableList.copyOf(proto.getNewNamePathList()); } ResolvedRenameStmt( ImmutableList hintList, String objectType, ImmutableList oldNamePath, ImmutableList newNamePath) { super( hintList); this.objectType = objectType; this.oldNamePath = oldNamePath; this.newNamePath = newNamePath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.objectType = this.getObjectType(); builder.oldNamePath = this.getOldNamePath(); builder.newNamePath = this.getNewNamePath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected String objectType = null; protected ImmutableList oldNamePath = null; protected ImmutableList newNamePath = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setObjectType(String v) { this.objectType = v; Preconditions.checkNotNull(v, "objectType must not be null"); return this; } @CanIgnoreReturnValue public Builder setOldNamePath(List v) { this.oldNamePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setNewNamePath(List v) { this.newNamePath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedRenameStmt build() { validate(); return new ResolvedRenameStmt( hintList, objectType, oldNamePath, newNamePath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( objectType != null, "objectType must be set"); Preconditions.checkArgument( oldNamePath != null, "oldNamePath must be set"); Preconditions.checkArgument( newNamePath != null, "newNamePath must be set"); } } public static final ResolvedRenameStmt deserialize( ResolvedRenameStmtProto proto, AbstractDeserializationHelper 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 public ResolvedRenameStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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] PRIVILEGE RESTRICTION [IF NOT EXISTS] * ON ON * [RESTRICT TO ()] * *

is the name of the column privileges on which * to apply the restrictions. * is a string identifier, which is currently either TABLE or * VIEW, which tells the engine how to look up the name. * is a list of users and groups the privilege restrictions * should apply to. Each restrictee is either a string * literal or a parameter. */ public static final class ResolvedCreatePrivilegeRestrictionStmt extends ResolvedCreateStatement { private final ImmutableList columnPrivilegeList; private final String objectType; private final ImmutableList restricteeList; ResolvedCreatePrivilegeRestrictionStmt(ResolvedCreatePrivilegeRestrictionStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder columnPrivilegeListBuilder = ImmutableList.builder(); for (ResolvedPrivilegeProto element : proto.getColumnPrivilegeListList()) { columnPrivilegeListBuilder .add(ResolvedPrivilege.deserialize(element, helper)); } columnPrivilegeList = columnPrivilegeListBuilder.build(); objectType = proto.getObjectType(); ImmutableList.Builder restricteeListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getRestricteeListList()) { restricteeListBuilder .add(ResolvedExpr.deserialize(element, helper)); } restricteeList = restricteeListBuilder.build(); } ResolvedCreatePrivilegeRestrictionStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList columnPrivilegeList, String objectType, ImmutableList restricteeList) { super( hintList, namePath, createScope, createMode); this.columnPrivilegeList = columnPrivilegeList; this.objectType = objectType; this.restricteeList = restricteeList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.columnPrivilegeList = this.getColumnPrivilegeList(); builder.objectType = this.getObjectType(); builder.restricteeList = this.getRestricteeList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList columnPrivilegeList = null; protected String objectType = null; protected ImmutableList restricteeList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setColumnPrivilegeList(List v) { this.columnPrivilegeList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setObjectType(String v) { this.objectType = v; Preconditions.checkNotNull(v, "objectType must not be null"); return this; } @CanIgnoreReturnValue public Builder setRestricteeList(List v) { this.restricteeList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCreatePrivilegeRestrictionStmt build() { validate(); return new ResolvedCreatePrivilegeRestrictionStmt( hintList, namePath, createScope, createMode, columnPrivilegeList, objectType, restricteeList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( columnPrivilegeList != null, "columnPrivilegeList must be set"); Preconditions.checkArgument( objectType != null, "objectType must be set"); } } public static final ResolvedCreatePrivilegeRestrictionStmt deserialize( ResolvedCreatePrivilegeRestrictionStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedCreatePrivilegeRestrictionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_PRIVILEGE_RESTRICTION_STMT; } @Override public final String nodeKindString() { return "CreatePrivilegeRestrictionStmt"; } /** * 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(); ResolvedCreatePrivilegeRestrictionStmtProto.Builder childBuilder = ResolvedCreatePrivilegeRestrictionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreatePrivilegeRestrictionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreatePrivilegeRestrictionStmtProto.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, ResolvedCreatePrivilegeRestrictionStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // columnPrivilegeList is a collection of AST nodes. Serialize each of them. ImmutableList columnPrivilegeLists = this.getColumnPrivilegeList(); for (ResolvedPrivilege element : columnPrivilegeLists) { ResolvedPrivilegeProto.Builder columnPrivilegeListBuilder = ResolvedPrivilegeProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, columnPrivilegeListBuilder); proto.addColumnPrivilegeList(columnPrivilegeListBuilder.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()); // restricteeList is a collection of AST nodes. Serialize each of them. ImmutableList restricteeLists = this.getRestricteeList(); for (ResolvedExpr element : restricteeLists) { AnyResolvedExprProto.Builder restricteeListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, restricteeListBuilder); proto.addRestricteeList(restricteeListBuilder.build()); } } public final ImmutableList getColumnPrivilegeList() { return columnPrivilegeList; } public final String getObjectType() { return objectType; } public final ImmutableList getRestricteeList() { return restricteeList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreatePrivilegeRestrictionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnPrivilegeList); visitor.descend(restricteeList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!columnPrivilegeList.isEmpty()) { fields.add(new DebugStringField("column_privilege_list", columnPrivilegeList)); } { fields.add(new DebugStringField("object_type", DebugStrings.toStringImpl(objectType))); } if (!restricteeList.isEmpty()) { fields.add(new DebugStringField("restrictee_list", restricteeList)); } } } /** * 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; ResolvedCreateRowAccessPolicyStmt(ResolvedCreateRowAccessPolicyStmtProto proto, AbstractDeserializationHelper 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(); } ResolvedCreateRowAccessPolicyStmt( ImmutableList hintList, CreateMode createMode, String name, ImmutableList targetNamePath, ImmutableList granteeList, ImmutableList granteeExprList, ResolvedTableScan tableScan, ResolvedExpr predicate, String predicateStr) { super( hintList); this.createMode = createMode; this.name = name; this.targetNamePath = targetNamePath; this.granteeList = granteeList; this.granteeExprList = granteeExprList; this.tableScan = tableScan; this.predicate = predicate; this.predicateStr = predicateStr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.createMode = this.getCreateMode(); builder.name = this.getName(); builder.targetNamePath = this.getTargetNamePath(); builder.granteeList = this.getGranteeList(); builder.granteeExprList = this.getGranteeExprList(); builder.tableScan = this.getTableScan(); builder.predicate = this.getPredicate(); builder.predicateStr = this.getPredicateStr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected CreateMode createMode = null; protected String name = null; protected ImmutableList targetNamePath = null; protected ImmutableList granteeList = null; protected ImmutableList granteeExprList = null; protected ResolvedTableScan tableScan = null; protected ResolvedExpr predicate = null; protected String predicateStr = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { this.createMode = v; return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; return this; } @CanIgnoreReturnValue public Builder setTargetNamePath(List v) { this.targetNamePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setGranteeList(List v) { this.granteeList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setGranteeExprList(List v) { this.granteeExprList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setTableScan(ResolvedTableScan v) { this.tableScan = v; return this; } @CanIgnoreReturnValue public Builder setPredicate(ResolvedExpr v) { this.predicate = v; return this; } @CanIgnoreReturnValue public Builder setPredicateStr(String v) { this.predicateStr = v; return this; } @Override public final ResolvedCreateRowAccessPolicyStmt build() { validate(); return new ResolvedCreateRowAccessPolicyStmt( hintList, createMode, name, targetNamePath, granteeList, granteeExprList, tableScan, predicate, predicateStr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( targetNamePath != null, "targetNamePath must be set"); } } public static final ResolvedCreateRowAccessPolicyStmt deserialize( ResolvedCreateRowAccessPolicyStmtProto proto, AbstractDeserializationHelper 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 public ResolvedCreateRowAccessPolicyStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(granteeExprList); visitor.descend(tableScan); visitor.descend(predicate); } public 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 PRIVILEGE RESTRICTION [IF EXISTS] * ON ON * *

is the name of the column privileges on which * the restrictions have been applied. * is a string identifier, which is currently either TABLE or * VIEW, which tells the engine how to look up the name. * is the name of the table the restrictions are scoped to. */ public static final class ResolvedDropPrivilegeRestrictionStmt extends ResolvedStatement { private final String objectType; private final boolean isIfExists; private final ImmutableList namePath; private final ImmutableList columnPrivilegeList; ResolvedDropPrivilegeRestrictionStmt(ResolvedDropPrivilegeRestrictionStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); objectType = proto.getObjectType(); isIfExists = proto.getIsIfExists(); namePath = ImmutableList.copyOf(proto.getNamePathList()); ImmutableList.Builder columnPrivilegeListBuilder = ImmutableList.builder(); for (ResolvedPrivilegeProto element : proto.getColumnPrivilegeListList()) { columnPrivilegeListBuilder .add(ResolvedPrivilege.deserialize(element, helper)); } columnPrivilegeList = columnPrivilegeListBuilder.build(); } ResolvedDropPrivilegeRestrictionStmt( ImmutableList hintList, String objectType, boolean isIfExists, ImmutableList namePath, ImmutableList columnPrivilegeList) { super( hintList); this.objectType = objectType; this.isIfExists = isIfExists; this.namePath = namePath; this.columnPrivilegeList = columnPrivilegeList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.objectType = this.getObjectType(); builder.isIfExists = this.getIsIfExists(); builder.namePath = this.getNamePath(); builder.columnPrivilegeList = this.getColumnPrivilegeList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected String objectType = null; protected Boolean isIfExists = null; protected ImmutableList namePath = null; protected ImmutableList columnPrivilegeList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setObjectType(String v) { this.objectType = v; Preconditions.checkNotNull(v, "objectType must not be null"); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setColumnPrivilegeList(List v) { this.columnPrivilegeList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedDropPrivilegeRestrictionStmt build() { validate(); return new ResolvedDropPrivilegeRestrictionStmt( hintList, objectType, isIfExists, namePath, columnPrivilegeList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( objectType != null, "objectType must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); Preconditions.checkArgument( columnPrivilegeList != null, "columnPrivilegeList must be set"); } } public static final ResolvedDropPrivilegeRestrictionStmt deserialize( ResolvedDropPrivilegeRestrictionStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedDropPrivilegeRestrictionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_PRIVILEGE_RESTRICTION_STMT; } @Override public final String nodeKindString() { return "DropPrivilegeRestrictionStmt"; } /** * 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(); ResolvedDropPrivilegeRestrictionStmtProto.Builder childBuilder = ResolvedDropPrivilegeRestrictionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropPrivilegeRestrictionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropPrivilegeRestrictionStmtProto.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, ResolvedDropPrivilegeRestrictionStmtProto.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()); // columnPrivilegeList is a collection of AST nodes. Serialize each of them. ImmutableList columnPrivilegeLists = this.getColumnPrivilegeList(); for (ResolvedPrivilege element : columnPrivilegeLists) { ResolvedPrivilegeProto.Builder columnPrivilegeListBuilder = ResolvedPrivilegeProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, columnPrivilegeListBuilder); proto.addColumnPrivilegeList(columnPrivilegeListBuilder.build()); } } public final String getObjectType() { return objectType; } public final boolean getIsIfExists() { return isIfExists; } public final ImmutableList getNamePath() { return namePath; } public final ImmutableList getColumnPrivilegeList() { return columnPrivilegeList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDropPrivilegeRestrictionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnPrivilegeList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("object_type", DebugStrings.toStringImpl(objectType))); } if (!DebugStrings.isDefaultValue(isIfExists)) { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (!columnPrivilegeList.isEmpty()) { fields.add(new DebugStringField("column_privilege_list", columnPrivilegeList)); } } } /** * 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; ResolvedDropRowAccessPolicyStmt(ResolvedDropRowAccessPolicyStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isDropAll = proto.getIsDropAll(); isIfExists = proto.getIsIfExists(); name = proto.getName(); targetNamePath = ImmutableList.copyOf(proto.getTargetNamePathList()); } ResolvedDropRowAccessPolicyStmt( ImmutableList hintList, boolean isDropAll, boolean isIfExists, String name, ImmutableList targetNamePath) { super( hintList); this.isDropAll = isDropAll; this.isIfExists = isIfExists; this.name = name; this.targetNamePath = targetNamePath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.isDropAll = this.getIsDropAll(); builder.isIfExists = this.getIsIfExists(); builder.name = this.getName(); builder.targetNamePath = this.getTargetNamePath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected Boolean isDropAll = null; protected Boolean isIfExists = null; protected String name = null; protected ImmutableList targetNamePath = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setIsDropAll(boolean v) { this.isDropAll = v; return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; return this; } @CanIgnoreReturnValue public Builder setTargetNamePath(List v) { this.targetNamePath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedDropRowAccessPolicyStmt build() { validate(); return new ResolvedDropRowAccessPolicyStmt( hintList, isDropAll, isIfExists, name, targetNamePath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( targetNamePath != null, "targetNamePath must be set"); } } public static final ResolvedDropRowAccessPolicyStmt deserialize( ResolvedDropRowAccessPolicyStmtProto proto, AbstractDeserializationHelper 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 public ResolvedDropRowAccessPolicyStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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))); } } } /** * DROP SEARCH|VECTOR INDEX [IF EXISTS] [ON ]; * Note: DROP INDEX without SEARCH or VECTOR is currently resolved to a * generic ResolvedDropStmt. The index_type currently would never be * INDEX_DEFAULT. * *

is the name of the search index to be dropped. * is a vector giving the identifier path of the target * table. */ public static final class ResolvedDropIndexStmt extends ResolvedStatement { private final boolean isIfExists; private final String name; private final ImmutableList tableNamePath; private final IndexType indexType; ResolvedDropIndexStmt(ResolvedDropIndexStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); name = proto.getName(); tableNamePath = ImmutableList.copyOf(proto.getTableNamePathList()); indexType = proto.getIndexType(); } ResolvedDropIndexStmt( ImmutableList hintList, boolean isIfExists, String name, ImmutableList tableNamePath, IndexType indexType) { super( hintList); this.isIfExists = isIfExists; this.name = name; this.tableNamePath = tableNamePath; this.indexType = indexType; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.isIfExists = this.getIsIfExists(); builder.name = this.getName(); builder.tableNamePath = this.getTableNamePath(); builder.indexType = this.getIndexType(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected Boolean isIfExists = null; protected String name = null; protected ImmutableList tableNamePath = null; protected IndexType indexType = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setTableNamePath(List v) { this.tableNamePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIndexType(IndexType v) { this.indexType = v; return this; } @Override public final ResolvedDropIndexStmt build() { validate(); return new ResolvedDropIndexStmt( hintList, isIfExists, name, tableNamePath, indexType); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfExists != null, "isIfExists must be set"); Preconditions.checkArgument( name != null, "name must be set"); Preconditions.checkArgument( tableNamePath != null, "tableNamePath must be set"); } } public static final ResolvedDropIndexStmt deserialize( ResolvedDropIndexStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedDropIndexStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_INDEX_STMT; } @Override public final String nodeKindString() { return "DropIndexStmt"; } /** * 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(); ResolvedDropIndexStmtProto.Builder childBuilder = ResolvedDropIndexStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropIndexStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropIndexStmtProto.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, ResolvedDropIndexStmtProto.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()); // 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()); // 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()); // indexType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIndexType(this.getIndexType()); } public final boolean getIsIfExists() { return isIfExists; } public final String getName() { return name; } public final ImmutableList getTableNamePath() { return tableNamePath; } public final IndexType getIndexType() { return indexType; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedDropIndexStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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))); } { fields.add(new DebugStringField("table_name_path", DebugStrings.toStringImpl(tableNamePath))); } if (!DebugStrings.isDefaultValue(indexType)) { fields.add(new DebugStringField("index_type", DebugStrings.toStringImpl(indexType))); } } } /** * 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; ResolvedGrantToAction(ResolvedGrantToActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder granteeExprListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getGranteeExprListList()) { granteeExprListBuilder .add(ResolvedExpr.deserialize(element, helper)); } granteeExprList = granteeExprListBuilder.build(); } ResolvedGrantToAction( ImmutableList granteeExprList) { super(); this.granteeExprList = granteeExprList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.granteeExprList = this.getGranteeExprList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected ImmutableList granteeExprList = null; private Builder() {} @CanIgnoreReturnValue public Builder setGranteeExprList(List v) { this.granteeExprList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGrantToAction build() { validate(); return new ResolvedGrantToAction( granteeExprList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( granteeExprList != null, "granteeExprList must be set"); } } public static final ResolvedGrantToAction deserialize( ResolvedGrantToActionProto proto, AbstractDeserializationHelper 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 public ResolvedGrantToAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(granteeExprList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!granteeExprList.isEmpty()) { fields.add(new DebugStringField("grantee_expr_list", granteeExprList)); } } } /** * This action for ALTER PRIVILEGE RESTRICTION statement: * RESTRICT TO * *

is a list of users and groups the privilege restrictions * should apply to. Each restrictee is either a string * literal or a parameter. */ public static final class ResolvedRestrictToAction extends ResolvedAlterAction { private final ImmutableList restricteeList; ResolvedRestrictToAction(ResolvedRestrictToActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder restricteeListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getRestricteeListList()) { restricteeListBuilder .add(ResolvedExpr.deserialize(element, helper)); } restricteeList = restricteeListBuilder.build(); } ResolvedRestrictToAction( ImmutableList restricteeList) { super(); this.restricteeList = restricteeList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.restricteeList = this.getRestricteeList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected ImmutableList restricteeList = null; private Builder() {} @CanIgnoreReturnValue public Builder setRestricteeList(List v) { this.restricteeList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedRestrictToAction build() { validate(); return new ResolvedRestrictToAction( restricteeList); } @Override protected void validate() { super.validate(); } } public static final ResolvedRestrictToAction deserialize( ResolvedRestrictToActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedRestrictToAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RESTRICT_TO_ACTION; } @Override public final String nodeKindString() { return "RestrictToAction"; } /** * 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(); ResolvedRestrictToActionProto.Builder childBuilder = ResolvedRestrictToActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRestrictToActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRestrictToActionProto.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, ResolvedRestrictToActionProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterActionProto parent = (ResolvedAlterActionProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // restricteeList is a collection of AST nodes. Serialize each of them. ImmutableList restricteeLists = this.getRestricteeList(); for (ResolvedExpr element : restricteeLists) { AnyResolvedExprProto.Builder restricteeListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, restricteeListBuilder); proto.addRestricteeList(restricteeListBuilder.build()); } } public final ImmutableList getRestricteeList() { return restricteeList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedRestrictToAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(restricteeList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!restricteeList.isEmpty()) { fields.add(new DebugStringField("restrictee_list", restricteeList)); } } } /** * This action for ALTER PRIVILEGE RESTRICTION statement: * ADD [IF NOT EXISTS] * *

is a list of users and groups the privilege restrictions * should apply to. Each restrictee is either a string * literal or a parameter. */ public static final class ResolvedAddToRestricteeListAction extends ResolvedAlterAction { private final boolean isIfNotExists; private final ImmutableList restricteeList; ResolvedAddToRestricteeListAction(ResolvedAddToRestricteeListActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfNotExists = proto.getIsIfNotExists(); ImmutableList.Builder restricteeListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getRestricteeListList()) { restricteeListBuilder .add(ResolvedExpr.deserialize(element, helper)); } restricteeList = restricteeListBuilder.build(); } ResolvedAddToRestricteeListAction( boolean isIfNotExists, ImmutableList restricteeList) { super(); this.isIfNotExists = isIfNotExists; this.restricteeList = restricteeList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfNotExists = this.getIsIfNotExists(); builder.restricteeList = this.getRestricteeList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected Boolean isIfNotExists = null; protected ImmutableList restricteeList = null; private Builder() {} @CanIgnoreReturnValue public Builder setIsIfNotExists(boolean v) { this.isIfNotExists = v; return this; } @CanIgnoreReturnValue public Builder setRestricteeList(List v) { this.restricteeList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedAddToRestricteeListAction build() { validate(); return new ResolvedAddToRestricteeListAction( isIfNotExists, restricteeList); } @Override protected void validate() { super.validate(); } } public static final ResolvedAddToRestricteeListAction deserialize( ResolvedAddToRestricteeListActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedAddToRestricteeListAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ADD_TO_RESTRICTEE_LIST_ACTION; } @Override public final String nodeKindString() { return "AddToRestricteeListAction"; } /** * 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(); ResolvedAddToRestricteeListActionProto.Builder childBuilder = ResolvedAddToRestricteeListActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAddToRestricteeListActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAddToRestricteeListActionProto.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, ResolvedAddToRestricteeListActionProto.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()); // restricteeList is a collection of AST nodes. Serialize each of them. ImmutableList restricteeLists = this.getRestricteeList(); for (ResolvedExpr element : restricteeLists) { AnyResolvedExprProto.Builder restricteeListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, restricteeListBuilder); proto.addRestricteeList(restricteeListBuilder.build()); } } public final boolean getIsIfNotExists() { return isIfNotExists; } public final ImmutableList getRestricteeList() { return restricteeList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAddToRestricteeListAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(restricteeList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(isIfNotExists)) { fields.add(new DebugStringField("is_if_not_exists", DebugStrings.toStringImpl(isIfNotExists))); } if (!restricteeList.isEmpty()) { fields.add(new DebugStringField("restrictee_list", restricteeList)); } } } /** * This action for ALTER PRIVILEGE RESTRICTION statement: * REMOVE [IF EXISTS] * *

is a list of users and groups the privilege restrictions * should apply to. Each restrictee is either a string * literal or a parameter. */ public static final class ResolvedRemoveFromRestricteeListAction extends ResolvedAlterAction { private final boolean isIfExists; private final ImmutableList restricteeList; ResolvedRemoveFromRestricteeListAction(ResolvedRemoveFromRestricteeListActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); ImmutableList.Builder restricteeListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getRestricteeListList()) { restricteeListBuilder .add(ResolvedExpr.deserialize(element, helper)); } restricteeList = restricteeListBuilder.build(); } ResolvedRemoveFromRestricteeListAction( boolean isIfExists, ImmutableList restricteeList) { super(); this.isIfExists = isIfExists; this.restricteeList = restricteeList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.isIfExists = this.getIsIfExists(); builder.restricteeList = this.getRestricteeList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected Boolean isIfExists = null; protected ImmutableList restricteeList = null; private Builder() {} @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setRestricteeList(List v) { this.restricteeList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedRemoveFromRestricteeListAction build() { validate(); return new ResolvedRemoveFromRestricteeListAction( isIfExists, restricteeList); } @Override protected void validate() { super.validate(); } } public static final ResolvedRemoveFromRestricteeListAction deserialize( ResolvedRemoveFromRestricteeListActionProto proto, AbstractDeserializationHelper helper) { return new ResolvedRemoveFromRestricteeListAction(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_REMOVE_FROM_RESTRICTEE_LIST_ACTION; } @Override public final String nodeKindString() { return "RemoveFromRestricteeListAction"; } /** * 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(); ResolvedRemoveFromRestricteeListActionProto.Builder childBuilder = ResolvedRemoveFromRestricteeListActionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedRemoveFromRestricteeListActionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedRemoveFromRestricteeListActionProto.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, ResolvedRemoveFromRestricteeListActionProto.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()); // restricteeList is a collection of AST nodes. Serialize each of them. ImmutableList restricteeLists = this.getRestricteeList(); for (ResolvedExpr element : restricteeLists) { AnyResolvedExprProto.Builder restricteeListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, restricteeListBuilder); proto.addRestricteeList(restricteeListBuilder.build()); } } public final boolean getIsIfExists() { return isIfExists; } public final ImmutableList getRestricteeList() { return restricteeList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedRemoveFromRestricteeListAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(restricteeList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(isIfExists)) { fields.add(new DebugStringField("is_if_exists", DebugStrings.toStringImpl(isIfExists))); } if (!restricteeList.isEmpty()) { fields.add(new DebugStringField("restrictee_list", restricteeList)); } } } /** * 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; ResolvedFilterUsingAction(ResolvedFilterUsingActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasPredicate()) { predicate = ResolvedExpr.deserialize(proto.getPredicate(), helper); } else { predicate = null; } predicateStr = proto.getPredicateStr(); } ResolvedFilterUsingAction( ResolvedExpr predicate, String predicateStr) { super(); this.predicate = predicate; this.predicateStr = predicateStr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.predicate = this.getPredicate(); builder.predicateStr = this.getPredicateStr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected ResolvedExpr predicate = null; protected String predicateStr = null; private Builder() {} @CanIgnoreReturnValue public Builder setPredicate(ResolvedExpr v) { this.predicate = v; return this; } @CanIgnoreReturnValue public Builder setPredicateStr(String v) { this.predicateStr = v; Preconditions.checkNotNull(v, "predicateStr must not be null"); return this; } @Override public final ResolvedFilterUsingAction build() { validate(); return new ResolvedFilterUsingAction( predicate, predicateStr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( predicateStr != null, "predicateStr must be set"); } } public static final ResolvedFilterUsingAction deserialize( ResolvedFilterUsingActionProto proto, AbstractDeserializationHelper 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 public ResolvedFilterUsingAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(predicate); } public 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; ResolvedRevokeFromAction(ResolvedRevokeFromActionProto proto, AbstractDeserializationHelper 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(); } ResolvedRevokeFromAction( ImmutableList revokeeExprList, boolean isRevokeFromAll) { super(); this.revokeeExprList = revokeeExprList; this.isRevokeFromAll = isRevokeFromAll; } @Override public Builder toBuilder() { Builder builder = builder(); builder.revokeeExprList = this.getRevokeeExprList(); builder.isRevokeFromAll = this.getIsRevokeFromAll(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected ImmutableList revokeeExprList = null; protected Boolean isRevokeFromAll = null; private Builder() {} @CanIgnoreReturnValue public Builder setRevokeeExprList(List v) { this.revokeeExprList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIsRevokeFromAll(boolean v) { this.isRevokeFromAll = v; return this; } @Override public final ResolvedRevokeFromAction build() { validate(); return new ResolvedRevokeFromAction( revokeeExprList, isRevokeFromAll); } @Override protected void validate() { super.validate(); } } public static final ResolvedRevokeFromAction deserialize( ResolvedRevokeFromActionProto proto, AbstractDeserializationHelper 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 public ResolvedRevokeFromAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(revokeeExprList); } public 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 * and ALTER TABLE statement * *

is the new name of the row access policy, * or the new path of the table. */ public static final class ResolvedRenameToAction extends ResolvedAlterAction { private final ImmutableList newPath; ResolvedRenameToAction(ResolvedRenameToActionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); newPath = ImmutableList.copyOf(proto.getNewPathList()); } ResolvedRenameToAction( ImmutableList newPath) { super(); this.newPath = newPath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.newPath = this.getNewPath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterAction.Builder { protected ImmutableList newPath = null; private Builder() {} @CanIgnoreReturnValue public Builder setNewPath(List v) { this.newPath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedRenameToAction build() { validate(); return new ResolvedRenameToAction( newPath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( newPath != null, "newPath must be set"); } } public static final ResolvedRenameToAction deserialize( ResolvedRenameToActionProto proto, AbstractDeserializationHelper 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); // newPath 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.addAllNewPath(this.getNewPath()); } public final ImmutableList getNewPath() { return newPath; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedRenameToAction accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("new_path", DebugStrings.toStringImpl(newPath))); } } } /** * This statement: * ALTER PRIVILEGE RESTRICTION [IF EXISTS] * ON ON * * *

is the name of the column privileges on which * the restrictions have been applied. * is a string identifier, which is currently either TABLE or * VIEW, which tells the engine how to look up the name. */ public static final class ResolvedAlterPrivilegeRestrictionStmt extends ResolvedAlterObjectStmt { private final ImmutableList columnPrivilegeList; private final String objectType; ResolvedAlterPrivilegeRestrictionStmt(ResolvedAlterPrivilegeRestrictionStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder columnPrivilegeListBuilder = ImmutableList.builder(); for (ResolvedPrivilegeProto element : proto.getColumnPrivilegeListList()) { columnPrivilegeListBuilder .add(ResolvedPrivilege.deserialize(element, helper)); } columnPrivilegeList = columnPrivilegeListBuilder.build(); objectType = proto.getObjectType(); } ResolvedAlterPrivilegeRestrictionStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists, ImmutableList columnPrivilegeList, String objectType) { super( hintList, namePath, alterActionList, isIfExists); this.columnPrivilegeList = columnPrivilegeList; this.objectType = objectType; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); builder.columnPrivilegeList = this.getColumnPrivilegeList(); builder.objectType = this.getObjectType(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { protected ImmutableList columnPrivilegeList = null; protected String objectType = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @CanIgnoreReturnValue public Builder setColumnPrivilegeList(List v) { this.columnPrivilegeList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setObjectType(String v) { this.objectType = v; Preconditions.checkNotNull(v, "objectType must not be null"); return this; } @Override public final ResolvedAlterPrivilegeRestrictionStmt build() { validate(); return new ResolvedAlterPrivilegeRestrictionStmt( hintList, namePath, alterActionList, isIfExists, columnPrivilegeList, objectType); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( columnPrivilegeList != null, "columnPrivilegeList must be set"); Preconditions.checkArgument( objectType != null, "objectType must be set"); } } public static final ResolvedAlterPrivilegeRestrictionStmt deserialize( ResolvedAlterPrivilegeRestrictionStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterPrivilegeRestrictionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_PRIVILEGE_RESTRICTION_STMT; } @Override public final String nodeKindString() { return "AlterPrivilegeRestrictionStmt"; } /** * 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(); ResolvedAlterPrivilegeRestrictionStmtProto.Builder childBuilder = ResolvedAlterPrivilegeRestrictionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterPrivilegeRestrictionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterPrivilegeRestrictionStmtProto.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, ResolvedAlterPrivilegeRestrictionStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterObjectStmtProto parent = (ResolvedAlterObjectStmtProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // columnPrivilegeList is a collection of AST nodes. Serialize each of them. ImmutableList columnPrivilegeLists = this.getColumnPrivilegeList(); for (ResolvedPrivilege element : columnPrivilegeLists) { ResolvedPrivilegeProto.Builder columnPrivilegeListBuilder = ResolvedPrivilegeProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, columnPrivilegeListBuilder); proto.addColumnPrivilegeList(columnPrivilegeListBuilder.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()); } public final ImmutableList getColumnPrivilegeList() { return columnPrivilegeList; } public final String getObjectType() { return objectType; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAlterPrivilegeRestrictionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnPrivilegeList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!columnPrivilegeList.isEmpty()) { fields.add(new DebugStringField("column_privilege_list", columnPrivilegeList)); } { fields.add(new DebugStringField("object_type", DebugStrings.toStringImpl(objectType))); } } } /** * 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; ResolvedAlterRowAccessPolicyStmt(ResolvedAlterRowAccessPolicyStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } } ResolvedAlterRowAccessPolicyStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists, String name, ResolvedTableScan tableScan) { super( hintList, namePath, alterActionList, isIfExists); this.name = name; this.tableScan = tableScan; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); builder.name = this.getName(); builder.tableScan = this.getTableScan(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { protected String name = null; protected ResolvedTableScan tableScan = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setTableScan(ResolvedTableScan v) { this.tableScan = v; return this; } @Override public final ResolvedAlterRowAccessPolicyStmt build() { validate(); return new ResolvedAlterRowAccessPolicyStmt( hintList, namePath, alterActionList, isIfExists, name, tableScan); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); } } public static final ResolvedAlterRowAccessPolicyStmt deserialize( ResolvedAlterRowAccessPolicyStmtProto proto, AbstractDeserializationHelper 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 public ResolvedAlterRowAccessPolicyStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); } public 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: * ALTER ALL ROW ACCESS POLICIES ON * *

is a vector giving the identifier path in the table name. * is a vector of actions to be done to the object. It * must have exactly one REVOKE FROM action with either * a non-empty grantee list or 'all'. * 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 ResolvedAlterAllRowAccessPoliciesStmt extends ResolvedAlterObjectStmt { private final ResolvedTableScan tableScan; ResolvedAlterAllRowAccessPoliciesStmt(ResolvedAlterAllRowAccessPoliciesStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasTableScan()) { tableScan = ResolvedTableScan.deserialize(proto.getTableScan(), helper); } else { tableScan = null; } } ResolvedAlterAllRowAccessPoliciesStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists, ResolvedTableScan tableScan) { super( hintList, namePath, alterActionList, isIfExists); this.tableScan = tableScan; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); builder.tableScan = this.getTableScan(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { protected ResolvedTableScan tableScan = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @CanIgnoreReturnValue public Builder setTableScan(ResolvedTableScan v) { this.tableScan = v; return this; } @Override public final ResolvedAlterAllRowAccessPoliciesStmt build() { validate(); return new ResolvedAlterAllRowAccessPoliciesStmt( hintList, namePath, alterActionList, isIfExists, tableScan); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterAllRowAccessPoliciesStmt deserialize( ResolvedAlterAllRowAccessPoliciesStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterAllRowAccessPoliciesStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_ALL_ROW_ACCESS_POLICIES_STMT; } @Override public final String nodeKindString() { return "AlterAllRowAccessPoliciesStmt"; } /** * 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(); ResolvedAlterAllRowAccessPoliciesStmtProto.Builder childBuilder = ResolvedAlterAllRowAccessPoliciesStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterAllRowAccessPoliciesStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterAllRowAccessPoliciesStmtProto.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, ResolvedAlterAllRowAccessPoliciesStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterObjectStmtProto parent = (ResolvedAlterObjectStmtProto) 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()); } } public final ResolvedTableScan getTableScan() { return tableScan; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAlterAllRowAccessPoliciesStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(tableScan); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); 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; ResolvedCreateConstantStmt(ResolvedCreateConstantStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } } ResolvedCreateConstantStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ResolvedExpr expr) { super( hintList, namePath, createScope, createMode); this.expr = expr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.expr = this.getExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected ResolvedExpr expr = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @Override public final ResolvedCreateConstantStmt build() { validate(); return new ResolvedCreateConstantStmt( hintList, namePath, createScope, createMode, expr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); } } public static final ResolvedCreateConstantStmt deserialize( ResolvedCreateConstantStmtProto proto, AbstractDeserializationHelper 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 public ResolvedCreateConstantStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public 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 ] [SQL SECURITY ] * [] * [[LANGUAGE ] [AS | AS ( )] * | REMOTE [WITH CONNECTION ]] * [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 'REMOTE' for remote * functions and otherwise to the language name specified in the * LANGUAGE clause. This field is set to 'REMOTE' iff is * set to true. * 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'. * is true if this is an remote function. It is true iff its * is set to 'REMOTE'. * is the identifier path of the connection object. It can be * only set when is true. * *

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, unless the function is * remote) 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; private final boolean isRemote; private final ResolvedConnection connection; ResolvedCreateFunctionStmt(ResolvedCreateFunctionStmtProto proto, AbstractDeserializationHelper 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(); isRemote = proto.getIsRemote(); if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } } ResolvedCreateFunctionStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, boolean hasExplicitReturnType, Type returnType, ImmutableList argumentNameList, FunctionSignature signature, boolean isAggregate, String language, String code, ImmutableList aggregateExpressionList, ResolvedExpr functionExpression, ImmutableList optionList, SqlSecurity sqlSecurity, DeterminismLevel determinismLevel, boolean isRemote, ResolvedConnection connection) { super( hintList, namePath, createScope, createMode); this.hasExplicitReturnType = hasExplicitReturnType; this.returnType = returnType; this.argumentNameList = argumentNameList; this.signature = signature; this.isAggregate = isAggregate; this.language = language; this.code = code; this.aggregateExpressionList = aggregateExpressionList; this.functionExpression = functionExpression; this.optionList = optionList; this.sqlSecurity = sqlSecurity; this.determinismLevel = determinismLevel; this.isRemote = isRemote; this.connection = connection; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.hasExplicitReturnType = this.getHasExplicitReturnType(); builder.returnType = this.getReturnType(); builder.argumentNameList = this.getArgumentNameList(); builder.signature = this.getSignature(); builder.isAggregate = this.getIsAggregate(); builder.language = this.getLanguage(); builder.code = this.getCode(); builder.aggregateExpressionList = this.getAggregateExpressionList(); builder.functionExpression = this.getFunctionExpression(); builder.optionList = this.getOptionList(); builder.sqlSecurity = this.getSqlSecurity(); builder.determinismLevel = this.getDeterminismLevel(); builder.isRemote = this.getIsRemote(); builder.connection = this.getConnection(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected Boolean hasExplicitReturnType = null; protected Type returnType = null; protected ImmutableList argumentNameList = null; protected FunctionSignature signature = null; protected Boolean isAggregate = null; protected String language = null; protected String code = null; protected ImmutableList aggregateExpressionList = null; protected ResolvedExpr functionExpression = null; protected ImmutableList optionList = null; protected SqlSecurity sqlSecurity = null; protected DeterminismLevel determinismLevel = null; protected Boolean isRemote = null; protected ResolvedConnection connection = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setHasExplicitReturnType(boolean v) { this.hasExplicitReturnType = v; return this; } @CanIgnoreReturnValue public Builder setReturnType(Type v) { this.returnType = v; return this; } @CanIgnoreReturnValue public Builder setArgumentNameList(List v) { this.argumentNameList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { this.signature = v; return this; } @CanIgnoreReturnValue public Builder setIsAggregate(boolean v) { this.isAggregate = v; return this; } @CanIgnoreReturnValue public Builder setLanguage(String v) { this.language = v; return this; } @CanIgnoreReturnValue public Builder setCode(String v) { this.code = v; return this; } @CanIgnoreReturnValue public Builder setAggregateExpressionList(List v) { this.aggregateExpressionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setFunctionExpression(ResolvedExpr v) { this.functionExpression = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setSqlSecurity(SqlSecurity v) { this.sqlSecurity = v; return this; } @CanIgnoreReturnValue public Builder setDeterminismLevel(DeterminismLevel v) { this.determinismLevel = v; return this; } @CanIgnoreReturnValue public Builder setIsRemote(boolean v) { this.isRemote = v; return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @Override public final ResolvedCreateFunctionStmt build() { validate(); return new ResolvedCreateFunctionStmt( hintList, namePath, createScope, createMode, hasExplicitReturnType, returnType, argumentNameList, signature, isAggregate, language, code, aggregateExpressionList, functionExpression, optionList, sqlSecurity, determinismLevel, isRemote, connection); } @Override protected void validate() { super.validate(); } } public static final ResolvedCreateFunctionStmt deserialize( ResolvedCreateFunctionStmtProto proto, AbstractDeserializationHelper 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()); // isRemote is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsRemote(this.getIsRemote()); // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.build()); } } 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; } public final boolean getIsRemote() { return isRemote; } public final ResolvedConnection getConnection() { return connection; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateFunctionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(aggregateExpressionList); visitor.descend(functionExpression); visitor.descend(optionList); visitor.descend(connection); } public 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))); } if (!DebugStrings.isDefaultValue(isRemote)) { fields.add(new DebugStringField("is_remote", DebugStrings.toStringImpl(isRemote))); } if (connection != null) { fields.add(new DebugStringField("connection", connection)); } } } /** * 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; ResolvedArgumentDef(ResolvedArgumentDefProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); type = helper.deserialize(proto.getType()); argumentKind = proto.getArgumentKind(); } ResolvedArgumentDef( String name, Type type, ArgumentKind argumentKind) { super(); this.name = name; this.type = type; this.argumentKind = argumentKind; } @Override public Builder toBuilder() { Builder builder = builder(); builder.name = this.getName(); builder.type = this.getType(); builder.argumentKind = this.getArgumentKind(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String name = null; protected Type type = null; protected ArgumentKind argumentKind = null; private Builder() {} @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; return this; } @CanIgnoreReturnValue public Builder setType(Type v) { this.type = v; Preconditions.checkNotNull(v, "type must not be null"); return this; } @CanIgnoreReturnValue public Builder setArgumentKind(ArgumentKind v) { this.argumentKind = v; return this; } @Override public final ResolvedArgumentDef build() { validate(); return new ResolvedArgumentDef( name, type, argumentKind); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( type != null, "type must be set"); } } public static final ResolvedArgumentDef deserialize( ResolvedArgumentDefProto proto, AbstractDeserializationHelper 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 public ResolvedArgumentDef accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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; ResolvedArgumentRef(ResolvedArgumentRefProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); argumentKind = proto.getArgumentKind(); } ResolvedArgumentRef( Type type, AnnotationMap typeAnnotationMap, String name, ArgumentKind argumentKind) { super( type, typeAnnotationMap); this.name = name; this.argumentKind = argumentKind; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.name = this.getName(); builder.argumentKind = this.getArgumentKind(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected String name = null; protected ArgumentKind argumentKind = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setArgumentKind(ArgumentKind v) { this.argumentKind = v; return this; } @Override public final ResolvedArgumentRef build() { validate(); return new ResolvedArgumentRef( type, typeAnnotationMap, name, argumentKind); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); } } public static final ResolvedArgumentRef deserialize( ResolvedArgumentRefProto proto, AbstractDeserializationHelper 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 public ResolvedArgumentRef accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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'. * is true iff RETURNS clause is present. * *

---------------------- * 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 boolean hasExplicitReturnSchema; 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; ResolvedCreateTableFunctionStmt(ResolvedCreateTableFunctionStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); argumentNameList = ImmutableList.copyOf(proto.getArgumentNameListList()); signature = helper.deserialize(proto.getSignature()); hasExplicitReturnSchema = proto.getHasExplicitReturnSchema(); 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(); } ResolvedCreateTableFunctionStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList argumentNameList, FunctionSignature signature, boolean hasExplicitReturnSchema, ImmutableList optionList, String language, String code, ResolvedScan query, ImmutableList outputColumnList, boolean isValueTable, SqlSecurity sqlSecurity) { super( hintList, namePath, createScope, createMode); this.argumentNameList = argumentNameList; this.signature = signature; this.hasExplicitReturnSchema = hasExplicitReturnSchema; this.optionList = optionList; this.language = language; this.code = code; this.query = query; this.outputColumnList = outputColumnList; this.isValueTable = isValueTable; this.sqlSecurity = sqlSecurity; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.argumentNameList = this.getArgumentNameList(); builder.signature = this.getSignature(); builder.hasExplicitReturnSchema = this.getHasExplicitReturnSchema(); builder.optionList = this.getOptionList(); builder.language = this.getLanguage(); builder.code = this.getCode(); builder.query = this.getQuery(); builder.outputColumnList = this.getOutputColumnList(); builder.isValueTable = this.getIsValueTable(); builder.sqlSecurity = this.getSqlSecurity(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList argumentNameList = null; protected FunctionSignature signature = null; protected Boolean hasExplicitReturnSchema = null; protected ImmutableList optionList = null; protected String language = null; protected String code = null; protected ResolvedScan query = null; protected ImmutableList outputColumnList = null; protected Boolean isValueTable = null; protected SqlSecurity sqlSecurity = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setArgumentNameList(List v) { this.argumentNameList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { this.signature = v; return this; } @CanIgnoreReturnValue public Builder setHasExplicitReturnSchema(boolean v) { this.hasExplicitReturnSchema = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setLanguage(String v) { this.language = v; return this; } @CanIgnoreReturnValue public Builder setCode(String v) { this.code = v; return this; } @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { this.query = v; return this; } @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { this.isValueTable = v; return this; } @CanIgnoreReturnValue public Builder setSqlSecurity(SqlSecurity v) { this.sqlSecurity = v; return this; } @Override public final ResolvedCreateTableFunctionStmt build() { validate(); return new ResolvedCreateTableFunctionStmt( hintList, namePath, createScope, createMode, argumentNameList, signature, hasExplicitReturnSchema, optionList, language, code, query, outputColumnList, isValueTable, sqlSecurity); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( outputColumnList != null, "outputColumnList must be set"); } } public static final ResolvedCreateTableFunctionStmt deserialize( ResolvedCreateTableFunctionStmtProto proto, AbstractDeserializationHelper 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)); } // hasExplicitReturnSchema is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setHasExplicitReturnSchema(this.getHasExplicitReturnSchema()); // 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 boolean getHasExplicitReturnSchema() { return hasExplicitReturnSchema; } 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 public ResolvedCreateTableFunctionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(query); visitor.descend(outputColumnList); } public 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 (!DebugStrings.isDefaultValue(hasExplicitReturnSchema)) { fields.add(new DebugStringField("has_explicit_return_schema", DebugStrings.toStringImpl(hasExplicitReturnSchema))); } 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; ResolvedRelationArgumentScan(ResolvedRelationArgumentScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); isValueTable = proto.getIsValueTable(); } ResolvedRelationArgumentScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, String name, boolean isValueTable) { super( columnList, hintList, isOrdered, nodeSource); this.name = name; this.isValueTable = isValueTable; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.name = this.getName(); builder.isValueTable = this.getIsValueTable(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected String name = null; protected Boolean isValueTable = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } /** * 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. */ @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } /** * 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). */ @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { this.isValueTable = v; return this; } @Override public final ResolvedRelationArgumentScan build() { validate(); return new ResolvedRelationArgumentScan( columnList, hintList, isOrdered, nodeSource, name, isValueTable); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); } } public static final ResolvedRelationArgumentScan deserialize( ResolvedRelationArgumentScanProto proto, AbstractDeserializationHelper 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 public ResolvedRelationArgumentScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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; ResolvedArgumentList(ResolvedArgumentListProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder argListBuilder = ImmutableList.builder(); for (ResolvedArgumentDefProto element : proto.getArgListList()) { argListBuilder .add(ResolvedArgumentDef.deserialize(element, helper)); } argList = argListBuilder.build(); } ResolvedArgumentList( ImmutableList argList) { super(); this.argList = argList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.argList = this.getArgList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList argList = null; private Builder() {} @CanIgnoreReturnValue public Builder setArgList(List v) { this.argList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedArgumentList build() { validate(); return new ResolvedArgumentList( argList); } @Override protected void validate() { super.validate(); } } public static final ResolvedArgumentList deserialize( ResolvedArgumentListProto proto, AbstractDeserializationHelper 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 public ResolvedArgumentList accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(argList); } public 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; ResolvedFunctionSignatureHolder(ResolvedFunctionSignatureHolderProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); signature = helper.deserialize(proto.getSignature()); } ResolvedFunctionSignatureHolder( FunctionSignature signature) { super(); this.signature = signature; } @Override public Builder toBuilder() { Builder builder = builder(); builder.signature = this.getSignature(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected FunctionSignature signature = null; private Builder() {} @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { this.signature = v; Preconditions.checkNotNull(v, "signature must not be null"); return this; } @Override public final ResolvedFunctionSignatureHolder build() { validate(); return new ResolvedFunctionSignatureHolder( signature); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( signature != null, "signature must be set"); } } public static final ResolvedFunctionSignatureHolder deserialize( ResolvedFunctionSignatureHolderProto proto, AbstractDeserializationHelper 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 public ResolvedFunctionSignatureHolder accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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; ResolvedDropFunctionStmt(ResolvedDropFunctionStmtProto proto, AbstractDeserializationHelper 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; } } ResolvedDropFunctionStmt( ImmutableList hintList, boolean isIfExists, ImmutableList namePath, ResolvedArgumentList arguments, ResolvedFunctionSignatureHolder signature) { super( hintList); this.isIfExists = isIfExists; this.namePath = namePath; this.arguments = arguments; this.signature = signature; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.isIfExists = this.getIsIfExists(); builder.namePath = this.getNamePath(); builder.arguments = this.getArguments(); builder.signature = this.getSignature(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected Boolean isIfExists = null; protected ImmutableList namePath = null; protected ResolvedArgumentList arguments = null; protected ResolvedFunctionSignatureHolder signature = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } /** * 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. */ @CanIgnoreReturnValue public Builder setArguments(ResolvedArgumentList v) { this.arguments = v; return this; } /** * 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. */ @CanIgnoreReturnValue public Builder setSignature(ResolvedFunctionSignatureHolder v) { this.signature = v; return this; } @Override public final ResolvedDropFunctionStmt build() { validate(); return new ResolvedDropFunctionStmt( hintList, isIfExists, namePath, arguments, signature); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfExists != null, "isIfExists must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedDropFunctionStmt deserialize( ResolvedDropFunctionStmtProto proto, AbstractDeserializationHelper 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 public ResolvedDropFunctionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(arguments); visitor.descend(signature); } public 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: DROP TABLE FUNCTION [IF EXISTS] ; * *

silently ignore the "name_path does not exist" error. * is the identifier path of the function to be dropped. */ public static final class ResolvedDropTableFunctionStmt extends ResolvedStatement { private final boolean isIfExists; private final ImmutableList namePath; ResolvedDropTableFunctionStmt(ResolvedDropTableFunctionStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isIfExists = proto.getIsIfExists(); namePath = ImmutableList.copyOf(proto.getNamePathList()); } ResolvedDropTableFunctionStmt( ImmutableList hintList, boolean isIfExists, ImmutableList namePath) { super( hintList); this.isIfExists = isIfExists; this.namePath = namePath; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.isIfExists = this.getIsIfExists(); builder.namePath = this.getNamePath(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected Boolean isIfExists = null; protected ImmutableList namePath = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { this.isIfExists = v; return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @Override public final ResolvedDropTableFunctionStmt build() { validate(); return new ResolvedDropTableFunctionStmt( hintList, isIfExists, namePath); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( isIfExists != null, "isIfExists must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedDropTableFunctionStmt deserialize( ResolvedDropTableFunctionStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedDropTableFunctionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_DROP_TABLE_FUNCTION_STMT; } @Override public final String nodeKindString() { return "DropTableFunctionStmt"; } /** * 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(); ResolvedDropTableFunctionStmtProto.Builder childBuilder = ResolvedDropTableFunctionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedDropTableFunctionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedDropTableFunctionStmtProto.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, ResolvedDropTableFunctionStmtProto.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 public ResolvedDropTableFunctionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public 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 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; ResolvedCallStmt(ResolvedCallStmtProto proto, AbstractDeserializationHelper 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(); } ResolvedCallStmt( ImmutableList hintList, Procedure procedure, FunctionSignature signature, ImmutableList argumentList) { super( hintList); this.procedure = procedure; this.signature = signature; this.argumentList = argumentList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.procedure = this.getProcedure(); builder.signature = this.getSignature(); builder.argumentList = this.getArgumentList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected Procedure procedure = null; protected FunctionSignature signature = null; protected ImmutableList argumentList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setProcedure(Procedure v) { this.procedure = v; Preconditions.checkNotNull(v, "procedure must not be null"); return this; } @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { this.signature = v; return this; } @CanIgnoreReturnValue public Builder setArgumentList(List v) { this.argumentList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCallStmt build() { validate(); return new ResolvedCallStmt( hintList, procedure, signature, argumentList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( procedure != null, "procedure must be set"); Preconditions.checkArgument( argumentList != null, "argumentList must be set"); } } public static final ResolvedCallStmt deserialize( ResolvedCallStmtProto proto, AbstractDeserializationHelper 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 public ResolvedCallStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(argumentList); } public 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; ResolvedImportStmt(ResolvedImportStmtProto proto, AbstractDeserializationHelper 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(); } ResolvedImportStmt( ImmutableList hintList, ImportKind importKind, ImmutableList namePath, String filePath, ImmutableList aliasPath, ImmutableList intoAliasPath, ImmutableList optionList) { super( hintList); this.importKind = importKind; this.namePath = namePath; this.filePath = filePath; this.aliasPath = aliasPath; this.intoAliasPath = intoAliasPath; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.importKind = this.getImportKind(); builder.namePath = this.getNamePath(); builder.filePath = this.getFilePath(); builder.aliasPath = this.getAliasPath(); builder.intoAliasPath = this.getIntoAliasPath(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ImportKind importKind = null; protected ImmutableList namePath = null; protected String filePath = null; protected ImmutableList aliasPath = null; protected ImmutableList intoAliasPath = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setImportKind(ImportKind v) { this.importKind = v; Preconditions.checkNotNull(v, "importKind must not be null"); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setFilePath(String v) { this.filePath = v; return this; } @CanIgnoreReturnValue public Builder setAliasPath(List v) { this.aliasPath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setIntoAliasPath(List v) { this.intoAliasPath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedImportStmt build() { validate(); return new ResolvedImportStmt( hintList, importKind, namePath, filePath, aliasPath, intoAliasPath, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( importKind != null, "importKind must be set"); } } public static final ResolvedImportStmt deserialize( ResolvedImportStmtProto proto, AbstractDeserializationHelper 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 public ResolvedImportStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public 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; ResolvedModuleStmt(ResolvedModuleStmtProto proto, AbstractDeserializationHelper 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(); } ResolvedModuleStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList optionList) { super( hintList); this.namePath = namePath; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ImmutableList namePath = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedModuleStmt build() { validate(); return new ResolvedModuleStmt( hintList, namePath, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedModuleStmt deserialize( ResolvedModuleStmtProto proto, AbstractDeserializationHelper 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 public ResolvedModuleStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public 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; ResolvedAggregateHavingModifier(ResolvedAggregateHavingModifierProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); kind = proto.getKind(); if (proto.hasHavingExpr()) { havingExpr = ResolvedExpr.deserialize(proto.getHavingExpr(), helper); } else { havingExpr = null; } } ResolvedAggregateHavingModifier( HavingModifierKind kind, ResolvedExpr havingExpr) { super(); this.kind = kind; this.havingExpr = havingExpr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.kind = this.getKind(); builder.havingExpr = this.getHavingExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected HavingModifierKind kind = null; protected ResolvedExpr havingExpr = null; private Builder() {} @CanIgnoreReturnValue public Builder setKind(HavingModifierKind v) { this.kind = v; Preconditions.checkNotNull(v, "kind must not be null"); return this; } @CanIgnoreReturnValue public Builder setHavingExpr(ResolvedExpr v) { this.havingExpr = v; Preconditions.checkNotNull(v, "havingExpr must not be null"); return this; } @Override public final ResolvedAggregateHavingModifier build() { validate(); return new ResolvedAggregateHavingModifier( kind, havingExpr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( kind != null, "kind must be set"); Preconditions.checkArgument( havingExpr != null, "havingExpr must be set"); } } public static final ResolvedAggregateHavingModifier deserialize( ResolvedAggregateHavingModifierProto proto, AbstractDeserializationHelper 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 public ResolvedAggregateHavingModifier accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(havingExpr); } public 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 ... | AS REPLICA OF ...} * *

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 partitionByList; private final ImmutableList clusterByList; private final ResolvedScan replicaSource; ResolvedCreateMaterializedViewStmt(ResolvedCreateMaterializedViewStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); 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(); if (proto.hasReplicaSource()) { replicaSource = ResolvedScan.deserialize(proto.getReplicaSource(), helper); } else { replicaSource = null; } } ResolvedCreateMaterializedViewStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ImmutableList outputColumnList, boolean hasExplicitColumns, ResolvedScan query, String sql, SqlSecurity sqlSecurity, boolean isValueTable, boolean recursive, ImmutableList columnDefinitionList, ImmutableList partitionByList, ImmutableList clusterByList, ResolvedScan replicaSource) { super( hintList, namePath, createScope, createMode, optionList, outputColumnList, hasExplicitColumns, query, sql, sqlSecurity, isValueTable, recursive, columnDefinitionList); this.partitionByList = partitionByList; this.clusterByList = clusterByList; this.replicaSource = replicaSource; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); builder.outputColumnList = this.getOutputColumnList(); builder.hasExplicitColumns = this.getHasExplicitColumns(); builder.query = this.getQuery(); builder.sql = this.getSql(); builder.sqlSecurity = this.getSqlSecurity(); builder.isValueTable = this.getIsValueTable(); builder.recursive = this.getRecursive(); builder.columnDefinitionList = this.getColumnDefinitionList(); builder.partitionByList = this.getPartitionByList(); builder.clusterByList = this.getClusterByList(); builder.replicaSource = this.getReplicaSource(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateViewBase.Builder { protected ImmutableList partitionByList = null; protected ImmutableList clusterByList = null; protected ResolvedScan replicaSource = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setOptionList(List v) { super.setOptionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { super.setOutputColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHasExplicitColumns(boolean v) { super.setHasExplicitColumns(v); return this; } @Override @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { super.setQuery(v); return this; } @Override @CanIgnoreReturnValue public Builder setSql(String v) { super.setSql(v); return this; } @Override @CanIgnoreReturnValue public Builder setSqlSecurity(SqlSecurity v) { super.setSqlSecurity(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { super.setIsValueTable(v); return this; } @Override @CanIgnoreReturnValue public Builder setRecursive(boolean v) { super.setRecursive(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { super.setColumnDefinitionList(v); return this; } @CanIgnoreReturnValue public Builder setPartitionByList(List v) { this.partitionByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setClusterByList(List v) { this.clusterByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setReplicaSource(ResolvedScan v) { this.replicaSource = v; return this; } @Override public final ResolvedCreateMaterializedViewStmt build() { validate(); return new ResolvedCreateMaterializedViewStmt( hintList, namePath, createScope, createMode, optionList, outputColumnList, hasExplicitColumns, query, sql, sqlSecurity, isValueTable, recursive, columnDefinitionList, partitionByList, clusterByList, replicaSource); } @Override protected void validate() { super.validate(); } } public static final ResolvedCreateMaterializedViewStmt deserialize( ResolvedCreateMaterializedViewStmtProto proto, AbstractDeserializationHelper 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); // 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()); } // replicaSource is an AST node. Call its serialization chain. if (this.getReplicaSource() != null) { AnyResolvedScanProto.Builder replicaSourceBuilder = AnyResolvedScanProto.newBuilder(); this.getReplicaSource().serialize( fileDescriptorSetsBuilder, replicaSourceBuilder); proto.setReplicaSource( replicaSourceBuilder.build()); } } public final ImmutableList getPartitionByList() { return partitionByList; } public final ImmutableList getClusterByList() { return clusterByList; } public final ResolvedScan getReplicaSource() { return replicaSource; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateMaterializedViewStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(partitionByList); visitor.descend(clusterByList); visitor.descend(replicaSource); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!partitionByList.isEmpty()) { fields.add(new DebugStringField("partition_by_list", partitionByList)); } if (!clusterByList.isEmpty()) { fields.add(new DebugStringField("cluster_by_list", clusterByList)); } if (replicaSource != null) { fields.add(new DebugStringField("replica_source", replicaSource)); } } } /** * This statement creates an APPROX VIEW: * CREATE APPROX VIEW [(...)] [OPTIONS (...)] AS SELECT ... * *

An APPROX VIEW provides approximate results from the view query, as * opposed to a regular view which returns exact results from its view query. * APPROX VIEW is a generic operator whose behavior is implementation-defined * based on the OPTIONS and query engines. * *

See (broken link) for more details on APPROX VIEW. */ public static final class ResolvedCreateApproxViewStmt extends ResolvedCreateViewBase { ResolvedCreateApproxViewStmt(ResolvedCreateApproxViewStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedCreateApproxViewStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList, ImmutableList outputColumnList, boolean hasExplicitColumns, ResolvedScan query, String sql, SqlSecurity sqlSecurity, boolean isValueTable, boolean recursive, ImmutableList columnDefinitionList) { super( hintList, namePath, createScope, createMode, optionList, outputColumnList, hasExplicitColumns, query, sql, sqlSecurity, isValueTable, recursive, columnDefinitionList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); builder.outputColumnList = this.getOutputColumnList(); builder.hasExplicitColumns = this.getHasExplicitColumns(); builder.query = this.getQuery(); builder.sql = this.getSql(); builder.sqlSecurity = this.getSqlSecurity(); builder.isValueTable = this.getIsValueTable(); builder.recursive = this.getRecursive(); builder.columnDefinitionList = this.getColumnDefinitionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateViewBase.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @Override @CanIgnoreReturnValue public Builder setOptionList(List v) { super.setOptionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { super.setOutputColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHasExplicitColumns(boolean v) { super.setHasExplicitColumns(v); return this; } @Override @CanIgnoreReturnValue public Builder setQuery(ResolvedScan v) { super.setQuery(v); return this; } @Override @CanIgnoreReturnValue public Builder setSql(String v) { super.setSql(v); return this; } @Override @CanIgnoreReturnValue public Builder setSqlSecurity(SqlSecurity v) { super.setSqlSecurity(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsValueTable(boolean v) { super.setIsValueTable(v); return this; } @Override @CanIgnoreReturnValue public Builder setRecursive(boolean v) { super.setRecursive(v); return this; } @Override @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { super.setColumnDefinitionList(v); return this; } @Override public final ResolvedCreateApproxViewStmt build() { validate(); return new ResolvedCreateApproxViewStmt( hintList, namePath, createScope, createMode, optionList, outputColumnList, hasExplicitColumns, query, sql, sqlSecurity, isValueTable, recursive, columnDefinitionList); } @Override protected void validate() { super.validate(); } } public static final ResolvedCreateApproxViewStmt deserialize( ResolvedCreateApproxViewStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedCreateApproxViewStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_APPROX_VIEW_STMT; } @Override public final String nodeKindString() { return "CreateApproxViewStmt"; } /** * 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(); ResolvedCreateApproxViewStmtProto.Builder childBuilder = ResolvedCreateApproxViewStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateApproxViewStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateApproxViewStmtProto.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, ResolvedCreateApproxViewStmtProto.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 public ResolvedCreateApproxViewStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This statement creates a user-defined procedure: * CREATE [OR REPLACE] [TEMP] PROCEDURE [IF NOT EXISTS] * () [EXTERNAL SECURITY ] * [WITH CONNECTION ] [OPTIONS ()] * [BEGIN END | LANGUAGE [AS ]]; * *

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. * is the external security mode for the created * procedure. Values include 'INVOKER', 'DEFINER'. * is the identifier path of the connection object. * has engine-specific directives for modifying procedures. * is a string literal that contains the SQL procedure * body. It includes everything from the BEGIN keyword to the END * keyword, inclusive. This will always be set for SQL procedures * and unset for external language procedures. * * 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. * is the programming language used by the procedure. This field * is set to the language name specified in the LANGUAGE clause. * Exactly one of and must be set. * is a string literal that contains the external language procedure * definition. It is allowed only if is set. */ public static final class ResolvedCreateProcedureStmt extends ResolvedCreateStatement { private final ImmutableList argumentNameList; private final FunctionSignature signature; private final ImmutableList optionList; private final String procedureBody; private final ResolvedConnection connection; private final String language; private final String code; private final SqlSecurity externalSecurity; ResolvedCreateProcedureStmt(ResolvedCreateProcedureStmtProto proto, AbstractDeserializationHelper 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(); if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } language = proto.getLanguage(); code = proto.getCode(); externalSecurity = proto.getExternalSecurity(); } ResolvedCreateProcedureStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList argumentNameList, FunctionSignature signature, ImmutableList optionList, String procedureBody, ResolvedConnection connection, String language, String code, SqlSecurity externalSecurity) { super( hintList, namePath, createScope, createMode); this.argumentNameList = argumentNameList; this.signature = signature; this.optionList = optionList; this.procedureBody = procedureBody; this.connection = connection; this.language = language; this.code = code; this.externalSecurity = externalSecurity; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.argumentNameList = this.getArgumentNameList(); builder.signature = this.getSignature(); builder.optionList = this.getOptionList(); builder.procedureBody = this.getProcedureBody(); builder.connection = this.getConnection(); builder.language = this.getLanguage(); builder.code = this.getCode(); builder.externalSecurity = this.getExternalSecurity(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList argumentNameList = null; protected FunctionSignature signature = null; protected ImmutableList optionList = null; protected String procedureBody = null; protected ResolvedConnection connection = null; protected String language = null; protected String code = null; protected SqlSecurity externalSecurity = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setArgumentNameList(List v) { this.argumentNameList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setSignature(FunctionSignature v) { this.signature = v; Preconditions.checkNotNull(v, "signature must not be null"); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setProcedureBody(String v) { this.procedureBody = v; return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @CanIgnoreReturnValue public Builder setLanguage(String v) { this.language = v; return this; } @CanIgnoreReturnValue public Builder setCode(String v) { this.code = v; return this; } @CanIgnoreReturnValue public Builder setExternalSecurity(SqlSecurity v) { this.externalSecurity = v; return this; } @Override public final ResolvedCreateProcedureStmt build() { validate(); return new ResolvedCreateProcedureStmt( hintList, namePath, createScope, createMode, argumentNameList, signature, optionList, procedureBody, connection, language, code, externalSecurity); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( argumentNameList != null, "argumentNameList must be set"); Preconditions.checkArgument( signature != null, "signature must be set"); } } public static final ResolvedCreateProcedureStmt deserialize( ResolvedCreateProcedureStmtProto proto, AbstractDeserializationHelper 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()); // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.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()); // externalSecurity is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setExternalSecurity(this.getExternalSecurity()); } public final ImmutableList getArgumentNameList() { return argumentNameList; } public final FunctionSignature getSignature() { return signature; } public final ImmutableList getOptionList() { return optionList; } public final String getProcedureBody() { return procedureBody; } public final ResolvedConnection getConnection() { return connection; } public final String getLanguage() { return language; } public final String getCode() { return code; } public final SqlSecurity getExternalSecurity() { return externalSecurity; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateProcedureStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(connection); } public 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)); } if (!DebugStrings.isDefaultValue(procedureBody)) { fields.add(new DebugStringField("procedure_body", DebugStrings.toStringImpl(procedureBody))); } if (connection != null) { fields.add(new DebugStringField("connection", connection)); } 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 (!DebugStrings.isDefaultValue(externalSecurity)) { fields.add(new DebugStringField("external_security", DebugStrings.toStringImpl(externalSecurity))); } } } /** * An argument for an EXECUTE IMMEDIATE's USING clause. * *

an optional name for this expression * the expression's value */ public static final class ResolvedExecuteImmediateArgument extends ResolvedArgument { private final String name; private final ResolvedExpr expression; ResolvedExecuteImmediateArgument(ResolvedExecuteImmediateArgumentProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); if (proto.hasExpression()) { expression = ResolvedExpr.deserialize(proto.getExpression(), helper); } else { expression = null; } } ResolvedExecuteImmediateArgument( String name, ResolvedExpr expression) { super(); this.name = name; this.expression = expression; } @Override public Builder toBuilder() { Builder builder = builder(); builder.name = this.getName(); builder.expression = this.getExpression(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String name = null; protected ResolvedExpr expression = null; private Builder() {} @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setExpression(ResolvedExpr v) { this.expression = v; Preconditions.checkNotNull(v, "expression must not be null"); return this; } @Override public final ResolvedExecuteImmediateArgument build() { validate(); return new ResolvedExecuteImmediateArgument( name, expression); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); Preconditions.checkArgument( expression != null, "expression must be set"); } } public static final ResolvedExecuteImmediateArgument deserialize( ResolvedExecuteImmediateArgumentProto proto, AbstractDeserializationHelper helper) { return new ResolvedExecuteImmediateArgument(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXECUTE_IMMEDIATE_ARGUMENT; } @Override public final String nodeKindString() { return "ExecuteImmediateArgument"; } /** * 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(); ResolvedExecuteImmediateArgumentProto.Builder childBuilder = ResolvedExecuteImmediateArgumentProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExecuteImmediateArgumentNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExecuteImmediateArgumentProto.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, ResolvedExecuteImmediateArgumentProto.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()); // 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 String getName() { return name; } public final ResolvedExpr getExpression() { return expression; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedExecuteImmediateArgument accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expression); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (expression != null) { fields.add(new DebugStringField("expression", expression)); } } } /** * An EXECUTE IMMEDIATE statement * EXECUTE IMMEDIATE [] [] * *

a string expression indicating a SQL statement to be dynamically * executed * the identifiers whose values should be set. * Identifiers should not be repeated in the list. * a list of arguments to supply for dynamic SQL. * The arguments should either be all named or all unnamed, and * arguments should not be repeated in the list. */ public static final class ResolvedExecuteImmediateStmt extends ResolvedStatement { private final ResolvedExpr sql; private final ImmutableList intoIdentifierList; private final ImmutableList usingArgumentList; ResolvedExecuteImmediateStmt(ResolvedExecuteImmediateStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasSql()) { sql = ResolvedExpr.deserialize(proto.getSql(), helper); } else { sql = null; } intoIdentifierList = ImmutableList.copyOf(proto.getIntoIdentifierListList()); ImmutableList.Builder usingArgumentListBuilder = ImmutableList.builder(); for (ResolvedExecuteImmediateArgumentProto element : proto.getUsingArgumentListList()) { usingArgumentListBuilder .add(ResolvedExecuteImmediateArgument.deserialize(element, helper)); } usingArgumentList = usingArgumentListBuilder.build(); } ResolvedExecuteImmediateStmt( ImmutableList hintList, ResolvedExpr sql, ImmutableList intoIdentifierList, ImmutableList usingArgumentList) { super( hintList); this.sql = sql; this.intoIdentifierList = intoIdentifierList; this.usingArgumentList = usingArgumentList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.sql = this.getSql(); builder.intoIdentifierList = this.getIntoIdentifierList(); builder.usingArgumentList = this.getUsingArgumentList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedExpr sql = null; protected ImmutableList intoIdentifierList = null; protected ImmutableList usingArgumentList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setSql(ResolvedExpr v) { this.sql = v; Preconditions.checkNotNull(v, "sql must not be null"); return this; } @CanIgnoreReturnValue public Builder setIntoIdentifierList(List v) { this.intoIdentifierList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setUsingArgumentList(List v) { this.usingArgumentList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedExecuteImmediateStmt build() { validate(); return new ResolvedExecuteImmediateStmt( hintList, sql, intoIdentifierList, usingArgumentList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( sql != null, "sql must be set"); Preconditions.checkArgument( intoIdentifierList != null, "intoIdentifierList must be set"); Preconditions.checkArgument( usingArgumentList != null, "usingArgumentList must be set"); } } public static final ResolvedExecuteImmediateStmt deserialize( ResolvedExecuteImmediateStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedExecuteImmediateStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_EXECUTE_IMMEDIATE_STMT; } @Override public final String nodeKindString() { return "ExecuteImmediateStmt"; } /** * 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(); ResolvedExecuteImmediateStmtProto.Builder childBuilder = ResolvedExecuteImmediateStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedExecuteImmediateStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedExecuteImmediateStmtProto.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, ResolvedExecuteImmediateStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // sql is an AST node. Call its serialization chain. if (this.getSql() != null) { AnyResolvedExprProto.Builder sqlBuilder = AnyResolvedExprProto.newBuilder(); this.getSql().serialize( fileDescriptorSetsBuilder, sqlBuilder); proto.setSql( sqlBuilder.build()); } // intoIdentifierList 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.addAllIntoIdentifierList(this.getIntoIdentifierList()); // usingArgumentList is a collection of AST nodes. Serialize each of them. ImmutableList usingArgumentLists = this.getUsingArgumentList(); for (ResolvedExecuteImmediateArgument element : usingArgumentLists) { ResolvedExecuteImmediateArgumentProto.Builder usingArgumentListBuilder = ResolvedExecuteImmediateArgumentProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, usingArgumentListBuilder); proto.addUsingArgumentList(usingArgumentListBuilder.build()); } } public final ResolvedExpr getSql() { return sql; } public final ImmutableList getIntoIdentifierList() { return intoIdentifierList; } public final ImmutableList getUsingArgumentList() { return usingArgumentList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedExecuteImmediateStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(sql); visitor.descend(usingArgumentList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (sql != null) { fields.add(new DebugStringField("sql", sql)); } { fields.add(new DebugStringField("into_identifier_list", DebugStrings.toStringCommaSeparated(intoIdentifierList))); } if (!usingArgumentList.isEmpty()) { fields.add(new DebugStringField("using_argument_list", usingArgumentList)); } } } /** * An assignment of a value to another value. */ public static final class ResolvedAssignmentStmt extends ResolvedStatement { /** * Target of the assignment. Currently, this will be * either ResolvedSystemVariable, or a chain of ResolveGetField * operations around it. */ private final ResolvedExpr target; /** * Value to assign into the target. This will always be * the same type as the target. */ private final ResolvedExpr expr; ResolvedAssignmentStmt(ResolvedAssignmentStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasTarget()) { target = ResolvedExpr.deserialize(proto.getTarget(), helper); } else { target = null; } if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } } ResolvedAssignmentStmt( ImmutableList hintList, ResolvedExpr target, ResolvedExpr expr) { super( hintList); this.target = target; this.expr = expr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.target = this.getTarget(); builder.expr = this.getExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedExpr target = null; protected ResolvedExpr expr = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } /** * Target of the assignment. Currently, this will be * either ResolvedSystemVariable, or a chain of ResolveGetField * operations around it. */ @CanIgnoreReturnValue public Builder setTarget(ResolvedExpr v) { this.target = v; Preconditions.checkNotNull(v, "target must not be null"); return this; } /** * Value to assign into the target. This will always be * the same type as the target. */ @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @Override public final ResolvedAssignmentStmt build() { validate(); return new ResolvedAssignmentStmt( hintList, target, expr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( target != null, "target must be set"); Preconditions.checkArgument( expr != null, "expr must be set"); } } public static final ResolvedAssignmentStmt deserialize( ResolvedAssignmentStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAssignmentStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ASSIGNMENT_STMT; } @Override public final String nodeKindString() { return "AssignmentStmt"; } /** * 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(); ResolvedAssignmentStmtProto.Builder childBuilder = ResolvedAssignmentStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAssignmentStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAssignmentStmtProto.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, ResolvedAssignmentStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) 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()); } // 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()); } } /** * Target of the assignment. Currently, this will be * either ResolvedSystemVariable, or a chain of ResolveGetField * operations around it. */ public final ResolvedExpr getTarget() { return target; } /** * Value to assign into the target. This will always be * the same type as the target. */ public final ResolvedExpr getExpr() { return expr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAssignmentStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(target); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (target != null) { fields.add(new DebugStringField("target", target)); } if (expr != null) { fields.add(new DebugStringField("expr", expr)); } } } /** * (broken link) * This statement: * CREATE [OR REPLACE] [IF NOT EXISTS] * [OPTIONS ] * [AS ]; * *

At most one of , can be non-empty. * *

engine-specific entity type to be created. * is a JSON literal to be interpreted by engine. * is a text literal to be interpreted by engine. * has engine-specific directives for how to * create this entity. */ public static final class ResolvedCreateEntityStmt extends ResolvedCreateStatement { private final String entityType; private final String entityBodyJson; private final String entityBodyText; private final ImmutableList optionList; ResolvedCreateEntityStmt(ResolvedCreateEntityStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); entityType = proto.getEntityType(); entityBodyJson = proto.getEntityBodyJson(); entityBodyText = proto.getEntityBodyText(); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedCreateEntityStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, String entityType, String entityBodyJson, String entityBodyText, ImmutableList optionList) { super( hintList, namePath, createScope, createMode); this.entityType = entityType; this.entityBodyJson = entityBodyJson; this.entityBodyText = entityBodyText; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.entityType = this.getEntityType(); builder.entityBodyJson = this.getEntityBodyJson(); builder.entityBodyText = this.getEntityBodyText(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected String entityType = null; protected String entityBodyJson = null; protected String entityBodyText = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setEntityType(String v) { this.entityType = v; Preconditions.checkNotNull(v, "entityType must not be null"); return this; } @CanIgnoreReturnValue public Builder setEntityBodyJson(String v) { this.entityBodyJson = v; return this; } @CanIgnoreReturnValue public Builder setEntityBodyText(String v) { this.entityBodyText = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCreateEntityStmt build() { validate(); return new ResolvedCreateEntityStmt( hintList, namePath, createScope, createMode, entityType, entityBodyJson, entityBodyText, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( entityType != null, "entityType must be set"); } } public static final ResolvedCreateEntityStmt deserialize( ResolvedCreateEntityStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedCreateEntityStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_ENTITY_STMT; } @Override public final String nodeKindString() { return "CreateEntityStmt"; } /** * 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(); ResolvedCreateEntityStmtProto.Builder childBuilder = ResolvedCreateEntityStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateEntityStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateEntityStmtProto.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, ResolvedCreateEntityStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // entityType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEntityType(this.getEntityType()); // entityBodyJson is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEntityBodyJson(this.getEntityBodyJson()); // entityBodyText is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEntityBodyText(this.getEntityBodyText()); // 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 getEntityType() { return entityType; } public final String getEntityBodyJson() { return entityBodyJson; } public final String getEntityBodyText() { return entityBodyText; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreateEntityStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("entity_type", DebugStrings.toStringImpl(entityType))); } if (!DebugStrings.isDefaultValue(entityBodyJson)) { fields.add(new DebugStringField("entity_body_json", DebugStrings.toStringImpl(entityBodyJson))); } if (!DebugStrings.isDefaultValue(entityBodyText)) { fields.add(new DebugStringField("entity_body_text", DebugStrings.toStringImpl(entityBodyText))); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * (broken link) * This statement: * ALTER [IF EXISTS] * , ... * *

engine-specific entity type to be altered. */ public static final class ResolvedAlterEntityStmt extends ResolvedAlterObjectStmt { private final String entityType; ResolvedAlterEntityStmt(ResolvedAlterEntityStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); entityType = proto.getEntityType(); } ResolvedAlterEntityStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists, String entityType) { super( hintList, namePath, alterActionList, isIfExists); this.entityType = entityType; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); builder.entityType = this.getEntityType(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { protected String entityType = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @CanIgnoreReturnValue public Builder setEntityType(String v) { this.entityType = v; Preconditions.checkNotNull(v, "entityType must not be null"); return this; } @Override public final ResolvedAlterEntityStmt build() { validate(); return new ResolvedAlterEntityStmt( hintList, namePath, alterActionList, isIfExists, entityType); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( entityType != null, "entityType must be set"); } } public static final ResolvedAlterEntityStmt deserialize( ResolvedAlterEntityStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterEntityStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_ENTITY_STMT; } @Override public final String nodeKindString() { return "AlterEntityStmt"; } /** * 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(); ResolvedAlterEntityStmtProto.Builder childBuilder = ResolvedAlterEntityStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterEntityStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterEntityStmtProto.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, ResolvedAlterEntityStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedAlterObjectStmtProto parent = (ResolvedAlterObjectStmtProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // entityType is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setEntityType(this.getEntityType()); } public final String getEntityType() { return entityType; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAlterEntityStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("entity_type", DebugStrings.toStringImpl(entityType))); } } } /** * Represents a column produced by aggregating a particular pivot * expression over a subset of the input for which the FOR expression * matches a particular pivot value. This aggregation is further * broken up by the enclosing ResolvedPivotScan's groupby columns, * with each distinct value of the groupby columns producing a * separate row in the output. * *

In any pivot column, 'c', * 'c' is produced by aggregating pivot expression * * over input rows such that * IS NOT DISTINCT FROM * */ public static final class ResolvedPivotColumn extends ResolvedArgument { /** * The output column used to represent the result of the pivot. */ private final ResolvedColumn column; /** * Specifies the index of the pivot expression * within the enclosing ResolvedPivotScan's used to * determine the result of the column. */ private final long pivotExprIndex; /** * Specifies the index of the pivot value within * the enclosing ResolvedPivotScan's used to * determine the subset of input rows the pivot expression should be * evaluated over. */ private final long pivotValueIndex; ResolvedPivotColumn(ResolvedPivotColumnProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); column = helper.deserialize(proto.getColumn()); pivotExprIndex = proto.getPivotExprIndex(); pivotValueIndex = proto.getPivotValueIndex(); } ResolvedPivotColumn( ResolvedColumn column, long pivotExprIndex, long pivotValueIndex) { super(); this.column = column; this.pivotExprIndex = pivotExprIndex; this.pivotValueIndex = pivotValueIndex; } @Override public Builder toBuilder() { Builder builder = builder(); builder.column = this.getColumn(); builder.pivotExprIndex = this.getPivotExprIndex(); builder.pivotValueIndex = this.getPivotValueIndex(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedColumn column = null; protected Long pivotExprIndex = null; protected Long pivotValueIndex = null; private Builder() {} /** * The output column used to represent the result of the pivot. */ @CanIgnoreReturnValue public Builder setColumn(ResolvedColumn v) { this.column = v; Preconditions.checkNotNull(v, "column must not be null"); return this; } /** * Specifies the index of the pivot expression * within the enclosing ResolvedPivotScan's used to * determine the result of the column. */ @CanIgnoreReturnValue public Builder setPivotExprIndex(long v) { this.pivotExprIndex = v; return this; } /** * Specifies the index of the pivot value within * the enclosing ResolvedPivotScan's used to * determine the subset of input rows the pivot expression should be * evaluated over. */ @CanIgnoreReturnValue public Builder setPivotValueIndex(long v) { this.pivotValueIndex = v; return this; } @Override public final ResolvedPivotColumn build() { validate(); return new ResolvedPivotColumn( column, pivotExprIndex, pivotValueIndex); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( column != null, "column must be set"); Preconditions.checkArgument( pivotExprIndex != null, "pivotExprIndex must be set"); Preconditions.checkArgument( pivotValueIndex != null, "pivotValueIndex must be set"); } } public static final ResolvedPivotColumn deserialize( ResolvedPivotColumnProto proto, AbstractDeserializationHelper helper) { return new ResolvedPivotColumn(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PIVOT_COLUMN; } @Override public final String nodeKindString() { return "PivotColumn"; } /** * 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(); ResolvedPivotColumnProto.Builder childBuilder = ResolvedPivotColumnProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedPivotColumnNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedPivotColumnProto.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, ResolvedPivotColumnProto.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)); } // pivotExprIndex is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setPivotExprIndex(this.getPivotExprIndex()); // pivotValueIndex is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setPivotValueIndex(this.getPivotValueIndex()); } /** * The output column used to represent the result of the pivot. */ public final ResolvedColumn getColumn() { return column; } /** * Specifies the index of the pivot expression * within the enclosing ResolvedPivotScan's used to * determine the result of the column. */ public final long getPivotExprIndex() { return pivotExprIndex; } /** * Specifies the index of the pivot value within * the enclosing ResolvedPivotScan's used to * determine the subset of input rows the pivot expression should be * evaluated over. */ public final long getPivotValueIndex() { return pivotValueIndex; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedPivotColumn accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("column", DebugStrings.toStringImpl(column))); } { fields.add(new DebugStringField("pivot_expr_index", DebugStrings.toStringImpl(pivotExprIndex))); } { fields.add(new DebugStringField("pivot_value_index", DebugStrings.toStringImpl(pivotValueIndex))); } } } /** * A scan produced by the following SQL fragment: * PIVOT(... FOR ... IN (...)) * *

The column list of this scan consists of a subset of columns from * and . * *

Details: (broken link) */ public static final class ResolvedPivotScan extends ResolvedScan { /** * Input to the PIVOT clause */ private final ResolvedScan inputScan; /** * The columns from to group by. * The output will have one row for each distinct combination of * values for all grouping columns. (There will be one output row if * this list is empty.) * *

Each element is a ResolvedComputedColumn. The expression is always * a ResolvedColumnRef that references a column from . */ private final ImmutableList groupByList; /** * Pivot expressions which aggregate over the subset of * where matches each value in , plus * all columns in . */ private final ImmutableList pivotExprList; /** * Expression following the FOR keyword, to be evaluated over each row * in . This value is compared with each value in * to determine which columns the aggregation * results of should go to. */ private final ResolvedExpr forExpr; /** * A list of pivot values within the IN list, to be compared against * the result of for each row in the input table. Each * pivot value generates a distinct column in the output for each * pivot expression, representing the result of the corresponding * pivot expression over the subset of input where matches * this pivot value. * *

All pivot values in this list must have the same type as * and must be constant. */ private final ImmutableList pivotValueList; /** * List of columns created to store the output pivot columns. * Each is computed using one of pivot_expr_list and one of * pivot_value_list. */ private final ImmutableList pivotColumnList; ResolvedPivotScan(ResolvedPivotScanProto proto, AbstractDeserializationHelper 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 pivotExprListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getPivotExprListList()) { pivotExprListBuilder .add(ResolvedExpr.deserialize(element, helper)); } pivotExprList = pivotExprListBuilder.build(); if (proto.hasForExpr()) { forExpr = ResolvedExpr.deserialize(proto.getForExpr(), helper); } else { forExpr = null; } ImmutableList.Builder pivotValueListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getPivotValueListList()) { pivotValueListBuilder .add(ResolvedExpr.deserialize(element, helper)); } pivotValueList = pivotValueListBuilder.build(); ImmutableList.Builder pivotColumnListBuilder = ImmutableList.builder(); for (ResolvedPivotColumnProto element : proto.getPivotColumnListList()) { pivotColumnListBuilder .add(ResolvedPivotColumn.deserialize(element, helper)); } pivotColumnList = pivotColumnListBuilder.build(); } ResolvedPivotScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList groupByList, ImmutableList pivotExprList, ResolvedExpr forExpr, ImmutableList pivotValueList, ImmutableList pivotColumnList) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.groupByList = groupByList; this.pivotExprList = pivotExprList; this.forExpr = forExpr; this.pivotValueList = pivotValueList; this.pivotColumnList = pivotColumnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.groupByList = this.getGroupByList(); builder.pivotExprList = this.getPivotExprList(); builder.forExpr = this.getForExpr(); builder.pivotValueList = this.getPivotValueList(); builder.pivotColumnList = this.getPivotColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ImmutableList groupByList = null; protected ImmutableList pivotExprList = null; protected ResolvedExpr forExpr = null; protected ImmutableList pivotValueList = null; protected ImmutableList pivotColumnList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } /** * Input to the PIVOT clause */ @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } /** * The columns from to group by. * The output will have one row for each distinct combination of * values for all grouping columns. (There will be one output row if * this list is empty.) * *

Each element is a ResolvedComputedColumn. The expression is always * a ResolvedColumnRef that references a column from . */ @CanIgnoreReturnValue public Builder setGroupByList(List v) { this.groupByList = ImmutableList.copyOf(v); return this; } /** * Pivot expressions which aggregate over the subset of * where matches each value in , plus * all columns in . */ @CanIgnoreReturnValue public Builder setPivotExprList(List v) { this.pivotExprList = ImmutableList.copyOf(v); return this; } /** * Expression following the FOR keyword, to be evaluated over each row * in . This value is compared with each value in * to determine which columns the aggregation * results of should go to. */ @CanIgnoreReturnValue public Builder setForExpr(ResolvedExpr v) { this.forExpr = v; Preconditions.checkNotNull(v, "forExpr must not be null"); return this; } /** * A list of pivot values within the IN list, to be compared against * the result of for each row in the input table. Each * pivot value generates a distinct column in the output for each * pivot expression, representing the result of the corresponding * pivot expression over the subset of input where matches * this pivot value. * *

All pivot values in this list must have the same type as * and must be constant. */ @CanIgnoreReturnValue public Builder setPivotValueList(List v) { this.pivotValueList = ImmutableList.copyOf(v); return this; } /** * List of columns created to store the output pivot columns. * Each is computed using one of pivot_expr_list and one of * pivot_value_list. */ @CanIgnoreReturnValue public Builder setPivotColumnList(List v) { this.pivotColumnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedPivotScan build() { validate(); return new ResolvedPivotScan( columnList, hintList, isOrdered, nodeSource, inputScan, groupByList, pivotExprList, forExpr, pivotValueList, pivotColumnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( groupByList != null, "groupByList must be set"); Preconditions.checkArgument( pivotExprList != null, "pivotExprList must be set"); Preconditions.checkArgument( forExpr != null, "forExpr must be set"); Preconditions.checkArgument( pivotValueList != null, "pivotValueList must be set"); Preconditions.checkArgument( pivotColumnList != null, "pivotColumnList must be set"); } } public static final ResolvedPivotScan deserialize( ResolvedPivotScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedPivotScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PIVOT_SCAN; } @Override public final String nodeKindString() { return "PivotScan"; } /** * 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(); ResolvedPivotScanProto.Builder childBuilder = ResolvedPivotScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedPivotScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedPivotScanProto.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, ResolvedPivotScanProto.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()); } // pivotExprList is a collection of AST nodes. Serialize each of them. ImmutableList pivotExprLists = this.getPivotExprList(); for (ResolvedExpr element : pivotExprLists) { AnyResolvedExprProto.Builder pivotExprListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, pivotExprListBuilder); proto.addPivotExprList(pivotExprListBuilder.build()); } // forExpr is an AST node. Call its serialization chain. if (this.getForExpr() != null) { AnyResolvedExprProto.Builder forExprBuilder = AnyResolvedExprProto.newBuilder(); this.getForExpr().serialize( fileDescriptorSetsBuilder, forExprBuilder); proto.setForExpr( forExprBuilder.build()); } // pivotValueList is a collection of AST nodes. Serialize each of them. ImmutableList pivotValueLists = this.getPivotValueList(); for (ResolvedExpr element : pivotValueLists) { AnyResolvedExprProto.Builder pivotValueListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, pivotValueListBuilder); proto.addPivotValueList(pivotValueListBuilder.build()); } // pivotColumnList is a collection of AST nodes. Serialize each of them. ImmutableList pivotColumnLists = this.getPivotColumnList(); for (ResolvedPivotColumn element : pivotColumnLists) { ResolvedPivotColumnProto.Builder pivotColumnListBuilder = ResolvedPivotColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, pivotColumnListBuilder); proto.addPivotColumnList(pivotColumnListBuilder.build()); } } /** * Input to the PIVOT clause */ public final ResolvedScan getInputScan() { return inputScan; } /** * The columns from to group by. * The output will have one row for each distinct combination of * values for all grouping columns. (There will be one output row if * this list is empty.) * *

Each element is a ResolvedComputedColumn. The expression is always * a ResolvedColumnRef that references a column from . */ public final ImmutableList getGroupByList() { return groupByList; } /** * Pivot expressions which aggregate over the subset of * where matches each value in , plus * all columns in . */ public final ImmutableList getPivotExprList() { return pivotExprList; } /** * Expression following the FOR keyword, to be evaluated over each row * in . This value is compared with each value in * to determine which columns the aggregation * results of should go to. */ public final ResolvedExpr getForExpr() { return forExpr; } /** * A list of pivot values within the IN list, to be compared against * the result of for each row in the input table. Each * pivot value generates a distinct column in the output for each * pivot expression, representing the result of the corresponding * pivot expression over the subset of input where matches * this pivot value. * *

All pivot values in this list must have the same type as * and must be constant. */ public final ImmutableList getPivotValueList() { return pivotValueList; } /** * List of columns created to store the output pivot columns. * Each is computed using one of pivot_expr_list and one of * pivot_value_list. */ public final ImmutableList getPivotColumnList() { return pivotColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedPivotScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(groupByList); visitor.descend(pivotExprList); visitor.descend(forExpr); visitor.descend(pivotValueList); visitor.descend(pivotColumnList); } public 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 (!pivotExprList.isEmpty()) { fields.add(new DebugStringField("pivot_expr_list", pivotExprList)); } if (forExpr != null) { fields.add(new DebugStringField("for_expr", forExpr)); } if (!pivotValueList.isEmpty()) { fields.add(new DebugStringField("pivot_value_list", pivotValueList)); } if (!pivotColumnList.isEmpty()) { fields.add(new DebugStringField("pivot_column_list", pivotColumnList)); } } } /** * Represents the returning clause on a DML statement. */ public static final class ResolvedReturningClause extends ResolvedArgument { /** * Specifies the columns in the returned output row with column * names. It can reference columns from the target table scan * from INSERT/DELETE/UPDATE statements. Also this list * can have columns computed in the or an * as the last column. */ private final ImmutableList outputColumnList; /** * Represents the WITH ACTION column in as a * string type column. There are four valid values for this action * column: "INSERT", "REPLACE", "UPDATE", and "DELETE". */ private final ResolvedColumnHolder actionColumn; /** * Represents the computed expressions so they can be referenced in * . Worth noting, it can't see * and can only access columns from the DML statement target table. */ private final ImmutableList exprList; ResolvedReturningClause(ResolvedReturningClauseProto proto, AbstractDeserializationHelper 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.hasActionColumn()) { actionColumn = ResolvedColumnHolder.deserialize(proto.getActionColumn(), helper); } else { actionColumn = null; } ImmutableList.Builder exprListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getExprListList()) { exprListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } exprList = exprListBuilder.build(); } ResolvedReturningClause( ImmutableList outputColumnList, ResolvedColumnHolder actionColumn, ImmutableList exprList) { super(); this.outputColumnList = outputColumnList; this.actionColumn = actionColumn; this.exprList = exprList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.outputColumnList = this.getOutputColumnList(); builder.actionColumn = this.getActionColumn(); builder.exprList = this.getExprList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList outputColumnList = null; protected ResolvedColumnHolder actionColumn = null; protected ImmutableList exprList = null; private Builder() {} /** * Specifies the columns in the returned output row with column * names. It can reference columns from the target table scan * from INSERT/DELETE/UPDATE statements. Also this list * can have columns computed in the or an * as the last column. */ @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } /** * Represents the WITH ACTION column in as a * string type column. There are four valid values for this action * column: "INSERT", "REPLACE", "UPDATE", and "DELETE". */ @CanIgnoreReturnValue public Builder setActionColumn(ResolvedColumnHolder v) { this.actionColumn = v; Preconditions.checkNotNull(v, "actionColumn must not be null"); return this; } /** * Represents the computed expressions so they can be referenced in * . Worth noting, it can't see * and can only access columns from the DML statement target table. */ @CanIgnoreReturnValue public Builder setExprList(List v) { this.exprList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedReturningClause build() { validate(); return new ResolvedReturningClause( outputColumnList, actionColumn, exprList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( outputColumnList != null, "outputColumnList must be set"); Preconditions.checkArgument( actionColumn != null, "actionColumn must be set"); Preconditions.checkArgument( exprList != null, "exprList must be set"); } } public static final ResolvedReturningClause deserialize( ResolvedReturningClauseProto proto, AbstractDeserializationHelper helper) { return new ResolvedReturningClause(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_RETURNING_CLAUSE; } @Override public final String nodeKindString() { return "ReturningClause"; } /** * 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(); ResolvedReturningClauseProto.Builder childBuilder = ResolvedReturningClauseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedReturningClauseNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedReturningClauseProto.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, ResolvedReturningClauseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) 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()); } // actionColumn is an AST node. Call its serialization chain. if (this.getActionColumn() != null) { ResolvedColumnHolderProto.Builder actionColumnBuilder = ResolvedColumnHolderProto.newBuilder(); this.getActionColumn().serialize( fileDescriptorSetsBuilder, actionColumnBuilder); proto.setActionColumn( actionColumnBuilder.build()); } // 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()); } } /** * Specifies the columns in the returned output row with column * names. It can reference columns from the target table scan * from INSERT/DELETE/UPDATE statements. Also this list * can have columns computed in the or an * as the last column. */ public final ImmutableList getOutputColumnList() { return outputColumnList; } /** * Represents the WITH ACTION column in as a * string type column. There are four valid values for this action * column: "INSERT", "REPLACE", "UPDATE", and "DELETE". */ public final ResolvedColumnHolder getActionColumn() { return actionColumn; } /** * Represents the computed expressions so they can be referenced in * . Worth noting, it can't see * and can only access columns from the DML statement target table. */ public final ImmutableList getExprList() { return exprList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedReturningClause accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(outputColumnList); visitor.descend(actionColumn); visitor.descend(exprList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } if (actionColumn != null) { fields.add(new DebugStringField("action_column", actionColumn)); } if (!exprList.isEmpty()) { fields.add(new DebugStringField("expr_list", exprList)); } } } /** * A column group in the UNPIVOT IN clause. * *

Example: * 'a' in 'UNPIVOT(x FOR z IN (a , b , c))' * or '(a , b)' in 'UNPIVOT((x , y) FOR z IN ((a , b), (c , d))' */ public static final class ResolvedUnpivotArg extends ResolvedArgument { /** * A list of columns referencing an output column of the * of ResolvedUnpivotScan. The size of this vector is * the same as . */ private final ImmutableList columnList; ResolvedUnpivotArg(ResolvedUnpivotArgProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder columnListBuilder = ImmutableList.builder(); for (ResolvedColumnRefProto element : proto.getColumnListList()) { columnListBuilder .add(ResolvedColumnRef.deserialize(element, helper)); } columnList = columnListBuilder.build(); } ResolvedUnpivotArg( ImmutableList columnList) { super(); this.columnList = columnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ImmutableList columnList = null; private Builder() {} /** * A list of columns referencing an output column of the * of ResolvedUnpivotScan. The size of this vector is * the same as . */ @CanIgnoreReturnValue public Builder setColumnList(List v) { this.columnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedUnpivotArg build() { validate(); return new ResolvedUnpivotArg( columnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( columnList != null, "columnList must be set"); } } public static final ResolvedUnpivotArg deserialize( ResolvedUnpivotArgProto proto, AbstractDeserializationHelper helper) { return new ResolvedUnpivotArg(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_UNPIVOT_ARG; } @Override public final String nodeKindString() { return "UnpivotArg"; } /** * 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(); ResolvedUnpivotArgProto.Builder childBuilder = ResolvedUnpivotArgProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedUnpivotArgNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedUnpivotArgProto.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, ResolvedUnpivotArgProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // columnList is a collection of AST nodes. Serialize each of them. ImmutableList columnLists = this.getColumnList(); for (ResolvedColumnRef element : columnLists) { ResolvedColumnRefProto.Builder columnListBuilder = ResolvedColumnRefProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, columnListBuilder); proto.addColumnList(columnListBuilder.build()); } } /** * A list of columns referencing an output column of the * of ResolvedUnpivotScan. The size of this vector is * the same as . */ public final ImmutableList getColumnList() { return columnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedUnpivotArg accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(columnList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!columnList.isEmpty()) { fields.add(new DebugStringField("column_list", columnList)); } } } /** * A scan produced by the following SQL fragment: * UNPIVOT( * FOR * IN ()) * *

size of ([i], i.e. column groups inside * ) * = size of () * = Let's say num_value_columns * *

size of () * = size of () * = Let's say num_args * *

Here is how output rows are generated -- * for each input row : * for arg_index = 0 .. (num_args - 1) : * output a row with the original columns from * * plus * arg = [arg_index] * for value_column_index = 0 .. (num_value_columns - 1) : * output_value_column = [value_column_index] * input_arg_column = arg [value_column_index] * output_value_column = input_arg_column * * plus * = [arg_index] * * *

Hence the total number of rows generated in the output = * input rows * size of * *

For all column groups inside , datatype of * columns at the same position in the vector must be equivalent, and * also equivalent to the datatype of the column at the same position in * . * I.e. in the above pseudocode, datatypes must be equivalent for * output_value_column and input_arg_column. * Datatype of must be the same as datatype of * and can be string or int64. * *

Details: (broken link) */ public static final class ResolvedUnpivotScan extends ResolvedScan { private final ResolvedScan inputScan; /** * This is a list of one or more new columns added by UNPIVOT. * These new column(s) store the value of input columns that are in * the UNPIVOT IN clause. */ private final ImmutableList valueColumnList; /** * This is a new column added in the output for storing labels for * input columns groups that are present in the IN clause. Its * values are taken from . */ private final ResolvedColumn labelColumn; /** * String or integer literal for each column group in * . */ private final ImmutableList labelList; /** * The list of groups of columns in the UNPIVOT IN list. Each group * contains references to the output columns of of the * ResolvedUnpivotScan. The values of these columns are stored in the * new and the column group labels/names * in the . */ private final ImmutableList unpivotArgList; /** * The columns from that are not unpivoted in UNPIVOT * IN clause. Columns in and * are mutually exclusive and their union is the * complete set of columns in the unpivot input-source. * *

The expression of each ResolvedComputedColumn is a * ResolvedColumnRef that references a column from . */ private final ImmutableList projectedInputColumnList; /** * Whether we need to include the rows from output where ALL columns * from are null. */ private final boolean includeNulls; ResolvedUnpivotScan(ResolvedUnpivotScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } ImmutableList.Builder valueColumnListBuilder = ImmutableList.builder(); for (ResolvedColumnProto element : proto.getValueColumnListList()) { valueColumnListBuilder.add(helper.deserialize(element)); } valueColumnList = valueColumnListBuilder.build(); labelColumn = helper.deserialize(proto.getLabelColumn()); ImmutableList.Builder labelListBuilder = ImmutableList.builder(); for (ResolvedLiteralProto element : proto.getLabelListList()) { labelListBuilder .add(ResolvedLiteral.deserialize(element, helper)); } labelList = labelListBuilder.build(); ImmutableList.Builder unpivotArgListBuilder = ImmutableList.builder(); for (ResolvedUnpivotArgProto element : proto.getUnpivotArgListList()) { unpivotArgListBuilder .add(ResolvedUnpivotArg.deserialize(element, helper)); } unpivotArgList = unpivotArgListBuilder.build(); ImmutableList.Builder projectedInputColumnListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getProjectedInputColumnListList()) { projectedInputColumnListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } projectedInputColumnList = projectedInputColumnListBuilder.build(); includeNulls = proto.getIncludeNulls(); } ResolvedUnpivotScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList valueColumnList, ResolvedColumn labelColumn, ImmutableList labelList, ImmutableList unpivotArgList, ImmutableList projectedInputColumnList, boolean includeNulls) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.valueColumnList = valueColumnList; this.labelColumn = labelColumn; this.labelList = labelList; this.unpivotArgList = unpivotArgList; this.projectedInputColumnList = projectedInputColumnList; this.includeNulls = includeNulls; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.valueColumnList = this.getValueColumnList(); builder.labelColumn = this.getLabelColumn(); builder.labelList = this.getLabelList(); builder.unpivotArgList = this.getUnpivotArgList(); builder.projectedInputColumnList = this.getProjectedInputColumnList(); builder.includeNulls = this.getIncludeNulls(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ImmutableList valueColumnList = null; protected ResolvedColumn labelColumn = null; protected ImmutableList labelList = null; protected ImmutableList unpivotArgList = null; protected ImmutableList projectedInputColumnList = null; protected Boolean includeNulls = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } /** * This is a list of one or more new columns added by UNPIVOT. * These new column(s) store the value of input columns that are in * the UNPIVOT IN clause. */ @CanIgnoreReturnValue public Builder setValueColumnList(List v) { this.valueColumnList = ImmutableList.copyOf(v); return this; } /** * This is a new column added in the output for storing labels for * input columns groups that are present in the IN clause. Its * values are taken from . */ @CanIgnoreReturnValue public Builder setLabelColumn(ResolvedColumn v) { this.labelColumn = v; Preconditions.checkNotNull(v, "labelColumn must not be null"); return this; } /** * String or integer literal for each column group in * . */ @CanIgnoreReturnValue public Builder setLabelList(List v) { this.labelList = ImmutableList.copyOf(v); return this; } /** * The list of groups of columns in the UNPIVOT IN list. Each group * contains references to the output columns of of the * ResolvedUnpivotScan. The values of these columns are stored in the * new and the column group labels/names * in the . */ @CanIgnoreReturnValue public Builder setUnpivotArgList(List v) { this.unpivotArgList = ImmutableList.copyOf(v); return this; } /** * The columns from that are not unpivoted in UNPIVOT * IN clause. Columns in and * are mutually exclusive and their union is the * complete set of columns in the unpivot input-source. * *

The expression of each ResolvedComputedColumn is a * ResolvedColumnRef that references a column from . */ @CanIgnoreReturnValue public Builder setProjectedInputColumnList(List v) { this.projectedInputColumnList = ImmutableList.copyOf(v); return this; } /** * Whether we need to include the rows from output where ALL columns * from are null. */ @CanIgnoreReturnValue public Builder setIncludeNulls(boolean v) { this.includeNulls = v; return this; } @Override public final ResolvedUnpivotScan build() { validate(); return new ResolvedUnpivotScan( columnList, hintList, isOrdered, nodeSource, inputScan, valueColumnList, labelColumn, labelList, unpivotArgList, projectedInputColumnList, includeNulls); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( valueColumnList != null, "valueColumnList must be set"); Preconditions.checkArgument( labelColumn != null, "labelColumn must be set"); Preconditions.checkArgument( labelList != null, "labelList must be set"); Preconditions.checkArgument( unpivotArgList != null, "unpivotArgList must be set"); Preconditions.checkArgument( includeNulls != null, "includeNulls must be set"); } } public static final ResolvedUnpivotScan deserialize( ResolvedUnpivotScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedUnpivotScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_UNPIVOT_SCAN; } @Override public final String nodeKindString() { return "UnpivotScan"; } /** * 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(); ResolvedUnpivotScanProto.Builder childBuilder = ResolvedUnpivotScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedUnpivotScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedUnpivotScanProto.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, ResolvedUnpivotScanProto.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()); } // valueColumnList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList valueColumnLists = this.getValueColumnList(); for (ResolvedColumn element : valueColumnLists) { proto.addValueColumnList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } // labelColumn is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getLabelColumn() != null) { proto.setLabelColumn( ResolvedNodes.serialize(this.getLabelColumn(), fileDescriptorSetsBuilder)); } // labelList is a collection of AST nodes. Serialize each of them. ImmutableList labelLists = this.getLabelList(); for (ResolvedLiteral element : labelLists) { ResolvedLiteralProto.Builder labelListBuilder = ResolvedLiteralProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, labelListBuilder); proto.addLabelList(labelListBuilder.build()); } // unpivotArgList is a collection of AST nodes. Serialize each of them. ImmutableList unpivotArgLists = this.getUnpivotArgList(); for (ResolvedUnpivotArg element : unpivotArgLists) { ResolvedUnpivotArgProto.Builder unpivotArgListBuilder = ResolvedUnpivotArgProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, unpivotArgListBuilder); proto.addUnpivotArgList(unpivotArgListBuilder.build()); } // projectedInputColumnList is a collection of AST nodes. Serialize each of them. ImmutableList projectedInputColumnLists = this.getProjectedInputColumnList(); for (ResolvedComputedColumn element : projectedInputColumnLists) { ResolvedComputedColumnProto.Builder projectedInputColumnListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, projectedInputColumnListBuilder); proto.addProjectedInputColumnList(projectedInputColumnListBuilder.build()); } // includeNulls is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIncludeNulls(this.getIncludeNulls()); } public final ResolvedScan getInputScan() { return inputScan; } /** * This is a list of one or more new columns added by UNPIVOT. * These new column(s) store the value of input columns that are in * the UNPIVOT IN clause. */ public final ImmutableList getValueColumnList() { return valueColumnList; } /** * This is a new column added in the output for storing labels for * input columns groups that are present in the IN clause. Its * values are taken from . */ public final ResolvedColumn getLabelColumn() { return labelColumn; } /** * String or integer literal for each column group in * . */ public final ImmutableList getLabelList() { return labelList; } /** * The list of groups of columns in the UNPIVOT IN list. Each group * contains references to the output columns of of the * ResolvedUnpivotScan. The values of these columns are stored in the * new and the column group labels/names * in the . */ public final ImmutableList getUnpivotArgList() { return unpivotArgList; } /** * The columns from that are not unpivoted in UNPIVOT * IN clause. Columns in and * are mutually exclusive and their union is the * complete set of columns in the unpivot input-source. * *

The expression of each ResolvedComputedColumn is a * ResolvedColumnRef that references a column from . */ public final ImmutableList getProjectedInputColumnList() { return projectedInputColumnList; } /** * Whether we need to include the rows from output where ALL columns * from are null. */ public final boolean getIncludeNulls() { return includeNulls; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedUnpivotScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(labelList); visitor.descend(unpivotArgList); visitor.descend(projectedInputColumnList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } { fields.add(new DebugStringField("value_column_list", DebugStrings.toStringImpl(valueColumnList))); } { fields.add(new DebugStringField("label_column", DebugStrings.toStringImpl(labelColumn))); } if (!labelList.isEmpty()) { fields.add(new DebugStringField("label_list", labelList)); } if (!unpivotArgList.isEmpty()) { fields.add(new DebugStringField("unpivot_arg_list", unpivotArgList)); } if (!projectedInputColumnList.isEmpty()) { fields.add(new DebugStringField("projected_input_column_list", projectedInputColumnList)); } { fields.add(new DebugStringField("include_nulls", DebugStrings.toStringImpl(includeNulls))); } } } /** * A scan for row pattern recognition (the MATCH_RECOGNIZE clause). * See (broken link) for details. */ public static final class ResolvedMatchRecognizeScan extends ResolvedScan { private final ResolvedScan inputScan; private final ImmutableList optionList; /** * Partitioning columns for this pattern matching operation. * Pattern matching occurs on individual partitions, just like * windowing functions. * *

If this list is empty, the whole input table is a single * partition. * *

Partitioning columns are always part of the scan's output columns, * along with the measures. */ private final ResolvedWindowPartitioning partitionBy; /** * The ordering list can never be empty. * Collation & hints supported, just like in window specification. * However, ordinals are not allowed. */ private final ResolvedWindowOrdering orderBy; /** * The pattern variable definitions. This list is never empty, and * variable names must be unique (ignoring case). */ private final ImmutableList patternVariableDefinitionList; /** * The pattern expression to use when matching rows. All row pattern * variables referenced in this expression must be defined in * pattern_variable_definition_list. */ private final ResolvedMatchRecognizePatternExpr pattern; /** * Represents the AFTER MATCH SKIP clause. Can never be * 'UNSPECIFIED'. * See (broken link) for details. */ private final AfterMatchSkipMode afterMatchSkipMode; /** * The outputs as defined in the MEASURES clause. */ private final ImmutableList measureGroupList; ResolvedMatchRecognizeScan(ResolvedMatchRecognizeScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); 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 patternVariableDefinitionListBuilder = ImmutableList.builder(); for (ResolvedMatchRecognizeVariableDefinitionProto element : proto.getPatternVariableDefinitionListList()) { patternVariableDefinitionListBuilder .add(ResolvedMatchRecognizeVariableDefinition.deserialize(element, helper)); } patternVariableDefinitionList = patternVariableDefinitionListBuilder.build(); if (proto.hasPattern()) { pattern = ResolvedMatchRecognizePatternExpr.deserialize(proto.getPattern(), helper); } else { pattern = null; } afterMatchSkipMode = proto.getAfterMatchSkipMode(); ImmutableList.Builder measureGroupListBuilder = ImmutableList.builder(); for (ResolvedMeasureGroupProto element : proto.getMeasureGroupListList()) { measureGroupListBuilder .add(ResolvedMeasureGroup.deserialize(element, helper)); } measureGroupList = measureGroupListBuilder.build(); } ResolvedMatchRecognizeScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList optionList, ResolvedWindowPartitioning partitionBy, ResolvedWindowOrdering orderBy, ImmutableList patternVariableDefinitionList, ResolvedMatchRecognizePatternExpr pattern, AfterMatchSkipMode afterMatchSkipMode, ImmutableList measureGroupList) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.optionList = optionList; this.partitionBy = partitionBy; this.orderBy = orderBy; this.patternVariableDefinitionList = patternVariableDefinitionList; this.pattern = pattern; this.afterMatchSkipMode = afterMatchSkipMode; this.measureGroupList = measureGroupList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.optionList = this.getOptionList(); builder.partitionBy = this.getPartitionBy(); builder.orderBy = this.getOrderBy(); builder.patternVariableDefinitionList = this.getPatternVariableDefinitionList(); builder.pattern = this.getPattern(); builder.afterMatchSkipMode = this.getAfterMatchSkipMode(); builder.measureGroupList = this.getMeasureGroupList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ImmutableList optionList = null; protected ResolvedWindowPartitioning partitionBy = null; protected ResolvedWindowOrdering orderBy = null; protected ImmutableList patternVariableDefinitionList = null; protected ResolvedMatchRecognizePatternExpr pattern = null; protected AfterMatchSkipMode afterMatchSkipMode = null; protected ImmutableList measureGroupList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } /** * Partitioning columns for this pattern matching operation. * Pattern matching occurs on individual partitions, just like * windowing functions. * *

If this list is empty, the whole input table is a single * partition. * *

Partitioning columns are always part of the scan's output columns, * along with the measures. */ @CanIgnoreReturnValue public Builder setPartitionBy(ResolvedWindowPartitioning v) { this.partitionBy = v; Preconditions.checkNotNull(v, "partitionBy must not be null"); return this; } /** * The ordering list can never be empty. * Collation & hints supported, just like in window specification. * However, ordinals are not allowed. */ @CanIgnoreReturnValue public Builder setOrderBy(ResolvedWindowOrdering v) { this.orderBy = v; Preconditions.checkNotNull(v, "orderBy must not be null"); return this; } /** * The pattern variable definitions. This list is never empty, and * variable names must be unique (ignoring case). */ @CanIgnoreReturnValue public Builder setPatternVariableDefinitionList(List v) { this.patternVariableDefinitionList = ImmutableList.copyOf(v); return this; } /** * The pattern expression to use when matching rows. All row pattern * variables referenced in this expression must be defined in * pattern_variable_definition_list. */ @CanIgnoreReturnValue public Builder setPattern(ResolvedMatchRecognizePatternExpr v) { this.pattern = v; Preconditions.checkNotNull(v, "pattern must not be null"); return this; } /** * Represents the AFTER MATCH SKIP clause. Can never be * 'UNSPECIFIED'. * See (broken link) for details. */ @CanIgnoreReturnValue public Builder setAfterMatchSkipMode(AfterMatchSkipMode v) { this.afterMatchSkipMode = v; Preconditions.checkNotNull(v, "afterMatchSkipMode must not be null"); return this; } /** * The outputs as defined in the MEASURES clause. */ @CanIgnoreReturnValue public Builder setMeasureGroupList(List v) { this.measureGroupList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedMatchRecognizeScan build() { validate(); return new ResolvedMatchRecognizeScan( columnList, hintList, isOrdered, nodeSource, inputScan, optionList, partitionBy, orderBy, patternVariableDefinitionList, pattern, afterMatchSkipMode, measureGroupList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( optionList != null, "optionList must be set"); Preconditions.checkArgument( partitionBy != null, "partitionBy must be set"); Preconditions.checkArgument( orderBy != null, "orderBy must be set"); Preconditions.checkArgument( patternVariableDefinitionList != null, "patternVariableDefinitionList must be set"); Preconditions.checkArgument( pattern != null, "pattern must be set"); Preconditions.checkArgument( afterMatchSkipMode != null, "afterMatchSkipMode must be set"); Preconditions.checkArgument( measureGroupList != null, "measureGroupList must be set"); } } public static final ResolvedMatchRecognizeScan deserialize( ResolvedMatchRecognizeScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedMatchRecognizeScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MATCH_RECOGNIZE_SCAN; } @Override public final String nodeKindString() { return "MatchRecognizeScan"; } /** * 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(); ResolvedMatchRecognizeScanProto.Builder childBuilder = ResolvedMatchRecognizeScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMatchRecognizeScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMatchRecognizeScanProto.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, ResolvedMatchRecognizeScanProto.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()); } // 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()); } // 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()); } // patternVariableDefinitionList is a collection of AST nodes. Serialize each of them. ImmutableList patternVariableDefinitionLists = this.getPatternVariableDefinitionList(); for (ResolvedMatchRecognizeVariableDefinition element : patternVariableDefinitionLists) { ResolvedMatchRecognizeVariableDefinitionProto.Builder patternVariableDefinitionListBuilder = ResolvedMatchRecognizeVariableDefinitionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, patternVariableDefinitionListBuilder); proto.addPatternVariableDefinitionList(patternVariableDefinitionListBuilder.build()); } // pattern is an AST node. Call its serialization chain. if (this.getPattern() != null) { AnyResolvedMatchRecognizePatternExprProto.Builder patternBuilder = AnyResolvedMatchRecognizePatternExprProto.newBuilder(); this.getPattern().serialize( fileDescriptorSetsBuilder, patternBuilder); proto.setPattern( patternBuilder.build()); } // afterMatchSkipMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setAfterMatchSkipMode(this.getAfterMatchSkipMode()); // measureGroupList is a collection of AST nodes. Serialize each of them. ImmutableList measureGroupLists = this.getMeasureGroupList(); for (ResolvedMeasureGroup element : measureGroupLists) { ResolvedMeasureGroupProto.Builder measureGroupListBuilder = ResolvedMeasureGroupProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, measureGroupListBuilder); proto.addMeasureGroupList(measureGroupListBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ImmutableList getOptionList() { return optionList; } /** * Partitioning columns for this pattern matching operation. * Pattern matching occurs on individual partitions, just like * windowing functions. * *

If this list is empty, the whole input table is a single * partition. * *

Partitioning columns are always part of the scan's output columns, * along with the measures. */ public final ResolvedWindowPartitioning getPartitionBy() { return partitionBy; } /** * The ordering list can never be empty. * Collation & hints supported, just like in window specification. * However, ordinals are not allowed. */ public final ResolvedWindowOrdering getOrderBy() { return orderBy; } /** * The pattern variable definitions. This list is never empty, and * variable names must be unique (ignoring case). */ public final ImmutableList getPatternVariableDefinitionList() { return patternVariableDefinitionList; } /** * The pattern expression to use when matching rows. All row pattern * variables referenced in this expression must be defined in * pattern_variable_definition_list. */ public final ResolvedMatchRecognizePatternExpr getPattern() { return pattern; } /** * Represents the AFTER MATCH SKIP clause. Can never be * 'UNSPECIFIED'. * See (broken link) for details. */ public final AfterMatchSkipMode getAfterMatchSkipMode() { return afterMatchSkipMode; } /** * The outputs as defined in the MEASURES clause. */ public final ImmutableList getMeasureGroupList() { return measureGroupList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedMatchRecognizeScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(optionList); visitor.descend(partitionBy); visitor.descend(orderBy); visitor.descend(patternVariableDefinitionList); visitor.descend(pattern); visitor.descend(measureGroupList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (partitionBy != null) { fields.add(new DebugStringField("partition_by", partitionBy)); } if (orderBy != null) { fields.add(new DebugStringField("order_by", orderBy)); } if (!patternVariableDefinitionList.isEmpty()) { fields.add(new DebugStringField("pattern_variable_definition_list", patternVariableDefinitionList)); } if (pattern != null) { fields.add(new DebugStringField("pattern", pattern)); } { fields.add(new DebugStringField("after_match_skip_mode", DebugStrings.toStringImpl(afterMatchSkipMode))); } if (!measureGroupList.isEmpty()) { fields.add(new DebugStringField("measure_group_list", measureGroupList)); } } } /** * Must be contained directly in a ResolvedMatchRecognizeScan. Groups all * aggregations ranging over the same pattern variable in the MEASURES clause * a MATCH_RECOGNIZE. This is a similar concept to * ResolvedAnalyticFunctionGroup. * *

For example, for this MEASURES clause: * MEASURES max(A.x) - min(b.x - b.y), sum(c.x) - avg(x) - min(A.z) * There will be 4 groups: * 1. (A, [max(A.x), min(A.z)]) * 2. (b, [min(b.x - b.y)]) * 3. (c, sum(c.x)) * 4. [avg(x)] universal group. * *

The last group is the universal group. It ranges over all rows in the * match. There can only be one such group in the ResolvedMatchRecognizeScan. */ public static final class ResolvedMeasureGroup extends ResolvedArgument { /** * Nullptr for the universal group, or name of the referenced pattern * variable, in which case this must match the name exactly as listed * in the `pattern_variable_definition_list` of the enclosing * ResolvedMatchRecognizeScan. */ private final ResolvedMatchRecognizePatternVariableRef patternVariableRef; /** * Aggregations that are part of this group, all ranging over rows * assigned to the designated pattern variable. If this is the * universal group, the aggregations range over all rows in the * match. * This list is never empty. */ private final ImmutableList aggregateList; ResolvedMeasureGroup(ResolvedMeasureGroupProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasPatternVariableRef()) { patternVariableRef = ResolvedMatchRecognizePatternVariableRef.deserialize(proto.getPatternVariableRef(), helper); } else { patternVariableRef = null; } ImmutableList.Builder aggregateListBuilder = ImmutableList.builder(); for (AnyResolvedComputedColumnBaseProto element : proto.getAggregateListList()) { aggregateListBuilder .add(ResolvedComputedColumnBase.deserialize(element, helper)); } aggregateList = aggregateListBuilder.build(); } ResolvedMeasureGroup( ResolvedMatchRecognizePatternVariableRef patternVariableRef, ImmutableList aggregateList) { super(); this.patternVariableRef = patternVariableRef; this.aggregateList = aggregateList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.patternVariableRef = this.getPatternVariableRef(); builder.aggregateList = this.getAggregateList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedMatchRecognizePatternVariableRef patternVariableRef = null; protected ImmutableList aggregateList = null; private Builder() {} /** * Nullptr for the universal group, or name of the referenced pattern * variable, in which case this must match the name exactly as listed * in the `pattern_variable_definition_list` of the enclosing * ResolvedMatchRecognizeScan. */ @CanIgnoreReturnValue public Builder setPatternVariableRef(ResolvedMatchRecognizePatternVariableRef v) { this.patternVariableRef = v; return this; } /** * Aggregations that are part of this group, all ranging over rows * assigned to the designated pattern variable. If this is the * universal group, the aggregations range over all rows in the * match. * This list is never empty. */ @CanIgnoreReturnValue public Builder setAggregateList(List v) { this.aggregateList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedMeasureGroup build() { validate(); return new ResolvedMeasureGroup( patternVariableRef, aggregateList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( aggregateList != null, "aggregateList must be set"); } } public static final ResolvedMeasureGroup deserialize( ResolvedMeasureGroupProto proto, AbstractDeserializationHelper helper) { return new ResolvedMeasureGroup(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MEASURE_GROUP; } @Override public final String nodeKindString() { return "MeasureGroup"; } /** * 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(); ResolvedMeasureGroupProto.Builder childBuilder = ResolvedMeasureGroupProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMeasureGroupNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMeasureGroupProto.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, ResolvedMeasureGroupProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // patternVariableRef is an AST node. Call its serialization chain. if (this.getPatternVariableRef() != null) { ResolvedMatchRecognizePatternVariableRefProto.Builder patternVariableRefBuilder = ResolvedMatchRecognizePatternVariableRefProto.newBuilder(); this.getPatternVariableRef().serialize( fileDescriptorSetsBuilder, patternVariableRefBuilder); proto.setPatternVariableRef( patternVariableRefBuilder.build()); } // aggregateList is a collection of AST nodes. Serialize each of them. ImmutableList aggregateLists = this.getAggregateList(); for (ResolvedComputedColumnBase element : aggregateLists) { AnyResolvedComputedColumnBaseProto.Builder aggregateListBuilder = AnyResolvedComputedColumnBaseProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, aggregateListBuilder); proto.addAggregateList(aggregateListBuilder.build()); } } /** * Nullptr for the universal group, or name of the referenced pattern * variable, in which case this must match the name exactly as listed * in the `pattern_variable_definition_list` of the enclosing * ResolvedMatchRecognizeScan. */ public final ResolvedMatchRecognizePatternVariableRef getPatternVariableRef() { return patternVariableRef; } /** * Aggregations that are part of this group, all ranging over rows * assigned to the designated pattern variable. If this is the * universal group, the aggregations range over all rows in the * match. * This list is never empty. */ public final ImmutableList getAggregateList() { return aggregateList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedMeasureGroup accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(patternVariableRef); visitor.descend(aggregateList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (patternVariableRef != null) { fields.add(new DebugStringField("pattern_variable_ref", patternVariableRef)); } if (!aggregateList.isEmpty()) { fields.add(new DebugStringField("aggregate_list", aggregateList)); } } } /** * Represents a row pattern variable definition. * This node can only be used under ResolvedMatchRecognizeScan. */ public static final class ResolvedMatchRecognizeVariableDefinition extends ResolvedArgument { /** * The name of the pattern variable. The name cannot be * empty and must be unique (case-insensitively) within this * ResolvedMatchRecognizeScan, but every place this name is * referenced elsewhere (e.g. variable ref), it will be identical, * including case. */ private final String name; /** * Predicate for this pattern variable. This is a BOOL expression to * compute whether or not a given row can be qualified for this * pattern variable. */ private final ResolvedExpr predicate; ResolvedMatchRecognizeVariableDefinition(ResolvedMatchRecognizeVariableDefinitionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); if (proto.hasPredicate()) { predicate = ResolvedExpr.deserialize(proto.getPredicate(), helper); } else { predicate = null; } } ResolvedMatchRecognizeVariableDefinition( String name, ResolvedExpr predicate) { super(); this.name = name; this.predicate = predicate; } @Override public Builder toBuilder() { Builder builder = builder(); builder.name = this.getName(); builder.predicate = this.getPredicate(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String name = null; protected ResolvedExpr predicate = null; private Builder() {} /** * The name of the pattern variable. The name cannot be * empty and must be unique (case-insensitively) within this * ResolvedMatchRecognizeScan, but every place this name is * referenced elsewhere (e.g. variable ref), it will be identical, * including case. */ @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } /** * Predicate for this pattern variable. This is a BOOL expression to * compute whether or not a given row can be qualified for this * pattern variable. */ @CanIgnoreReturnValue public Builder setPredicate(ResolvedExpr v) { this.predicate = v; Preconditions.checkNotNull(v, "predicate must not be null"); return this; } @Override public final ResolvedMatchRecognizeVariableDefinition build() { validate(); return new ResolvedMatchRecognizeVariableDefinition( name, predicate); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); Preconditions.checkArgument( predicate != null, "predicate must be set"); } } public static final ResolvedMatchRecognizeVariableDefinition deserialize( ResolvedMatchRecognizeVariableDefinitionProto proto, AbstractDeserializationHelper helper) { return new ResolvedMatchRecognizeVariableDefinition(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MATCH_RECOGNIZE_VARIABLE_DEFINITION; } @Override public final String nodeKindString() { return "MatchRecognizeVariableDefinition"; } /** * 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(); ResolvedMatchRecognizeVariableDefinitionProto.Builder childBuilder = ResolvedMatchRecognizeVariableDefinitionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMatchRecognizeVariableDefinitionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMatchRecognizeVariableDefinitionProto.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, ResolvedMatchRecognizeVariableDefinitionProto.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()); // 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()); } } /** * The name of the pattern variable. The name cannot be * empty and must be unique (case-insensitively) within this * ResolvedMatchRecognizeScan, but every place this name is * referenced elsewhere (e.g. variable ref), it will be identical, * including case. */ public final String getName() { return name; } /** * Predicate for this pattern variable. This is a BOOL expression to * compute whether or not a given row can be qualified for this * pattern variable. */ public final ResolvedExpr getPredicate() { return predicate; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedMatchRecognizeVariableDefinition accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(predicate); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (predicate != null) { fields.add(new DebugStringField("predicate", predicate)); } } } /** * Abstract class for row pattern expression. */ public static abstract class ResolvedMatchRecognizePatternExpr extends ResolvedArgument { ResolvedMatchRecognizePatternExpr(ResolvedMatchRecognizePatternExprProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedMatchRecognizePatternExpr() { super(); } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedArgument.Builder { private Builder() {} @Override public abstract ResolvedMatchRecognizePatternExpr build(); @Override protected void validate() { super.validate(); } } public static ResolvedMatchRecognizePatternExpr deserialize( AnyResolvedMatchRecognizePatternExprProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_MATCH_RECOGNIZE_PATTERN_EMPTY_NODE: return ResolvedMatchRecognizePatternEmpty.deserialize( proto.getResolvedMatchRecognizePatternEmptyNode(), helper); case RESOLVED_MATCH_RECOGNIZE_PATTERN_VARIABLE_REF_NODE: return ResolvedMatchRecognizePatternVariableRef.deserialize( proto.getResolvedMatchRecognizePatternVariableRefNode(), helper); case RESOLVED_MATCH_RECOGNIZE_PATTERN_OPERATION_NODE: return ResolvedMatchRecognizePatternOperation.deserialize( proto.getResolvedMatchRecognizePatternOperationNode(), helper); case RESOLVED_MATCH_RECOGNIZE_PATTERN_QUANTIFICATION_NODE: return ResolvedMatchRecognizePatternQuantification.deserialize( proto.getResolvedMatchRecognizePatternQuantificationNode(), helper); case RESOLVED_MATCH_RECOGNIZE_PATTERN_ANCHOR_NODE: return ResolvedMatchRecognizePatternAnchor.deserialize( proto.getResolvedMatchRecognizePatternAnchorNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedMatchRecognizePatternExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedMatchRecognizePatternExprProto.Builder builder = ResolvedMatchRecognizePatternExprProto.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(); AnyResolvedMatchRecognizePatternExprProto.Builder childBuilder = AnyResolvedMatchRecognizePatternExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMatchRecognizePatternExprNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedMatchRecognizePatternExprProto.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, AnyResolvedMatchRecognizePatternExprProto.Builder builder); /** * Serializes this node into the given {@link ResolvedMatchRecognizePatternExprProto.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, ResolvedMatchRecognizePatternExprProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public abstract ResolvedMatchRecognizePatternExpr accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * Represents an empty pattern. * * An empty pattern consumes zero rows and always matches successfully. * * An empty pattern on zero input rows will not produce a match, since * matches are just searched for at each distinct start row. */ public static final class ResolvedMatchRecognizePatternEmpty extends ResolvedMatchRecognizePatternExpr { ResolvedMatchRecognizePatternEmpty(ResolvedMatchRecognizePatternEmptyProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedMatchRecognizePatternEmpty() { super(); } @Override public Builder toBuilder() { Builder builder = builder(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedMatchRecognizePatternExpr.Builder { private Builder() {} @Override public final ResolvedMatchRecognizePatternEmpty build() { validate(); return new ResolvedMatchRecognizePatternEmpty(); } @Override protected void validate() { super.validate(); } } public static final ResolvedMatchRecognizePatternEmpty deserialize( ResolvedMatchRecognizePatternEmptyProto proto, AbstractDeserializationHelper helper) { return new ResolvedMatchRecognizePatternEmpty(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MATCH_RECOGNIZE_PATTERN_EMPTY; } @Override public final String nodeKindString() { return "MatchRecognizePatternEmpty"; } /** * Serializes this node into a {@link AnyResolvedMatchRecognizePatternExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedMatchRecognizePatternExprProto.Builder builder = AnyResolvedMatchRecognizePatternExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedMatchRecognizePatternExprProto.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, AnyResolvedMatchRecognizePatternExprProto.Builder builder) { builder.clear(); ResolvedMatchRecognizePatternEmptyProto.Builder childBuilder = ResolvedMatchRecognizePatternEmptyProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMatchRecognizePatternEmptyNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMatchRecognizePatternEmptyProto.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, ResolvedMatchRecognizePatternEmptyProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedMatchRecognizePatternExprProto parent = (ResolvedMatchRecognizePatternExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedMatchRecognizePatternEmpty accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * Represents a start or end anchor (^ or $, respectively.) * * A START anchor requires the match to be at the start of the partition. * * An END anchor requires the match to be at the end of the partition. * * Just like the empty pattern, anchors consume zero rows and do not * produce matches on zero input rows. */ public static final class ResolvedMatchRecognizePatternAnchor extends ResolvedMatchRecognizePatternExpr { private final Mode mode; ResolvedMatchRecognizePatternAnchor(ResolvedMatchRecognizePatternAnchorProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); mode = proto.getMode(); } ResolvedMatchRecognizePatternAnchor( Mode mode) { super(); this.mode = mode; } @Override public Builder toBuilder() { Builder builder = builder(); builder.mode = this.getMode(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedMatchRecognizePatternExpr.Builder { protected Mode mode = null; private Builder() {} @CanIgnoreReturnValue public Builder setMode(Mode v) { this.mode = v; Preconditions.checkNotNull(v, "mode must not be null"); return this; } @Override public final ResolvedMatchRecognizePatternAnchor build() { validate(); return new ResolvedMatchRecognizePatternAnchor( mode); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( mode != null, "mode must be set"); } } public static final ResolvedMatchRecognizePatternAnchor deserialize( ResolvedMatchRecognizePatternAnchorProto proto, AbstractDeserializationHelper helper) { return new ResolvedMatchRecognizePatternAnchor(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MATCH_RECOGNIZE_PATTERN_ANCHOR; } @Override public final String nodeKindString() { return "MatchRecognizePatternAnchor"; } /** * Serializes this node into a {@link AnyResolvedMatchRecognizePatternExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedMatchRecognizePatternExprProto.Builder builder = AnyResolvedMatchRecognizePatternExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedMatchRecognizePatternExprProto.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, AnyResolvedMatchRecognizePatternExprProto.Builder builder) { builder.clear(); ResolvedMatchRecognizePatternAnchorProto.Builder childBuilder = ResolvedMatchRecognizePatternAnchorProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMatchRecognizePatternAnchorNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMatchRecognizePatternAnchorProto.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, ResolvedMatchRecognizePatternAnchorProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedMatchRecognizePatternExprProto parent = (ResolvedMatchRecognizePatternExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // mode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setMode(this.getMode()); } public final Mode getMode() { return mode; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedMatchRecognizePatternAnchor accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("mode", DebugStrings.toStringImpl(mode))); } } } /** * A reference to a row pattern variable. */ public static final class ResolvedMatchRecognizePatternVariableRef extends ResolvedMatchRecognizePatternExpr { /** * Name of the referenced pattern variable. This must match the * the name exactly as listed in the * `pattern_variable_definition_list` of the enclosing * ResolvedMatchRecognizeScan. */ private final String name; ResolvedMatchRecognizePatternVariableRef(ResolvedMatchRecognizePatternVariableRefProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); } ResolvedMatchRecognizePatternVariableRef( String name) { super(); this.name = name; } @Override public Builder toBuilder() { Builder builder = builder(); builder.name = this.getName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedMatchRecognizePatternExpr.Builder { protected String name = null; private Builder() {} /** * Name of the referenced pattern variable. This must match the * the name exactly as listed in the * `pattern_variable_definition_list` of the enclosing * ResolvedMatchRecognizeScan. */ @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @Override public final ResolvedMatchRecognizePatternVariableRef build() { validate(); return new ResolvedMatchRecognizePatternVariableRef( name); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); } } public static final ResolvedMatchRecognizePatternVariableRef deserialize( ResolvedMatchRecognizePatternVariableRefProto proto, AbstractDeserializationHelper helper) { return new ResolvedMatchRecognizePatternVariableRef(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MATCH_RECOGNIZE_PATTERN_VARIABLE_REF; } @Override public final String nodeKindString() { return "MatchRecognizePatternVariableRef"; } /** * Serializes this node into a {@link AnyResolvedMatchRecognizePatternExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedMatchRecognizePatternExprProto.Builder builder = AnyResolvedMatchRecognizePatternExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedMatchRecognizePatternExprProto.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, AnyResolvedMatchRecognizePatternExprProto.Builder builder) { builder.clear(); ResolvedMatchRecognizePatternVariableRefProto.Builder childBuilder = ResolvedMatchRecognizePatternVariableRefProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMatchRecognizePatternVariableRefNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMatchRecognizePatternVariableRefProto.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, ResolvedMatchRecognizePatternVariableRefProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedMatchRecognizePatternExprProto parent = (ResolvedMatchRecognizePatternExprProto) 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()); } /** * Name of the referenced pattern variable. This must match the * the name exactly as listed in the * `pattern_variable_definition_list` of the enclosing * ResolvedMatchRecognizeScan. */ public final String getName() { return name; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedMatchRecognizePatternVariableRef accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } } } /** * An N-ary operation over row pattern sub-expressions. */ public static final class ResolvedMatchRecognizePatternOperation extends ResolvedMatchRecognizePatternExpr { private final MatchRecognizePatternOperationType opType; private final ImmutableList operandList; ResolvedMatchRecognizePatternOperation(ResolvedMatchRecognizePatternOperationProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); opType = proto.getOpType(); ImmutableList.Builder operandListBuilder = ImmutableList.builder(); for (AnyResolvedMatchRecognizePatternExprProto element : proto.getOperandListList()) { operandListBuilder .add(ResolvedMatchRecognizePatternExpr.deserialize(element, helper)); } operandList = operandListBuilder.build(); } ResolvedMatchRecognizePatternOperation( MatchRecognizePatternOperationType opType, ImmutableList operandList) { super(); this.opType = opType; this.operandList = operandList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.opType = this.getOpType(); builder.operandList = this.getOperandList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedMatchRecognizePatternExpr.Builder { protected MatchRecognizePatternOperationType opType = null; protected ImmutableList operandList = null; private Builder() {} @CanIgnoreReturnValue public Builder setOpType(MatchRecognizePatternOperationType v) { this.opType = v; Preconditions.checkNotNull(v, "opType must not be null"); return this; } @CanIgnoreReturnValue public Builder setOperandList(List v) { this.operandList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedMatchRecognizePatternOperation build() { validate(); return new ResolvedMatchRecognizePatternOperation( opType, operandList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( opType != null, "opType must be set"); Preconditions.checkArgument( operandList != null, "operandList must be set"); } } public static final ResolvedMatchRecognizePatternOperation deserialize( ResolvedMatchRecognizePatternOperationProto proto, AbstractDeserializationHelper helper) { return new ResolvedMatchRecognizePatternOperation(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MATCH_RECOGNIZE_PATTERN_OPERATION; } @Override public final String nodeKindString() { return "MatchRecognizePatternOperation"; } /** * Serializes this node into a {@link AnyResolvedMatchRecognizePatternExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedMatchRecognizePatternExprProto.Builder builder = AnyResolvedMatchRecognizePatternExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedMatchRecognizePatternExprProto.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, AnyResolvedMatchRecognizePatternExprProto.Builder builder) { builder.clear(); ResolvedMatchRecognizePatternOperationProto.Builder childBuilder = ResolvedMatchRecognizePatternOperationProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMatchRecognizePatternOperationNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMatchRecognizePatternOperationProto.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, ResolvedMatchRecognizePatternOperationProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedMatchRecognizePatternExprProto parent = (ResolvedMatchRecognizePatternExprProto) 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()); // operandList is a collection of AST nodes. Serialize each of them. ImmutableList operandLists = this.getOperandList(); for (ResolvedMatchRecognizePatternExpr element : operandLists) { AnyResolvedMatchRecognizePatternExprProto.Builder operandListBuilder = AnyResolvedMatchRecognizePatternExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, operandListBuilder); proto.addOperandList(operandListBuilder.build()); } } public final MatchRecognizePatternOperationType getOpType() { return opType; } public final ImmutableList getOperandList() { return operandList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedMatchRecognizePatternOperation accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(operandList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("op_type", DebugStrings.toStringImpl(opType))); } if (!operandList.isEmpty()) { fields.add(new DebugStringField("operand_list", operandList)); } } } /** * Quantification on a row pattern expression, e.g. A+, A?, A{n, m}, ..etc. * Regardless of the original syntax used, e.g. a symbol or fixed- or custom- * bounded, e.g. A+, A{3} or A{1,2}?, the quantifier is represented by the * lower and upper bounds, and a boolean indicating whether the quantifier is * reluctant or not. * *

The upper and lower bounds are represented as ResolvedExprs, but currently * must be literals or parameters. Their type is INT64. * *

It is a runtime error if the upper bound is present and is smaller than * the lower bound. * Any pattern expression can be quantified, including already-quantified * pattern expressions, For example, the pattern expression * ( (A|B){2} ) {2,4} * specifies either 2, 3 or 4 *pairs* of rows, each matches A or B. */ public static final class ResolvedMatchRecognizePatternQuantification extends ResolvedMatchRecognizePatternExpr { /** * The sub-pattern to be repeated according to this quantifier. * Cannot be nullptr. */ private final ResolvedMatchRecognizePatternExpr operand; /** * Lower bound of the quantification. Cannot be nullptr. */ private final ResolvedExpr lowerBound; /** * The upper bound of the quantification. Can be nullptr, in which * case it means there is no upper bound (i.e., unlimited). */ private final ResolvedExpr upperBound; /** * If true, this quantifier is reluctant. If false, it is greedy. */ private final boolean isReluctant; ResolvedMatchRecognizePatternQuantification(ResolvedMatchRecognizePatternQuantificationProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasOperand()) { operand = ResolvedMatchRecognizePatternExpr.deserialize(proto.getOperand(), helper); } else { operand = null; } if (proto.hasLowerBound()) { lowerBound = ResolvedExpr.deserialize(proto.getLowerBound(), helper); } else { lowerBound = null; } if (proto.hasUpperBound()) { upperBound = ResolvedExpr.deserialize(proto.getUpperBound(), helper); } else { upperBound = null; } isReluctant = proto.getIsReluctant(); } ResolvedMatchRecognizePatternQuantification( ResolvedMatchRecognizePatternExpr operand, ResolvedExpr lowerBound, ResolvedExpr upperBound, boolean isReluctant) { super(); this.operand = operand; this.lowerBound = lowerBound; this.upperBound = upperBound; this.isReluctant = isReluctant; } @Override public Builder toBuilder() { Builder builder = builder(); builder.operand = this.getOperand(); builder.lowerBound = this.getLowerBound(); builder.upperBound = this.getUpperBound(); builder.isReluctant = this.getIsReluctant(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedMatchRecognizePatternExpr.Builder { protected ResolvedMatchRecognizePatternExpr operand = null; protected ResolvedExpr lowerBound = null; protected ResolvedExpr upperBound = null; protected Boolean isReluctant = null; private Builder() {} /** * The sub-pattern to be repeated according to this quantifier. * Cannot be nullptr. */ @CanIgnoreReturnValue public Builder setOperand(ResolvedMatchRecognizePatternExpr v) { this.operand = v; Preconditions.checkNotNull(v, "operand must not be null"); return this; } /** * Lower bound of the quantification. Cannot be nullptr. */ @CanIgnoreReturnValue public Builder setLowerBound(ResolvedExpr v) { this.lowerBound = v; Preconditions.checkNotNull(v, "lowerBound must not be null"); return this; } /** * The upper bound of the quantification. Can be nullptr, in which * case it means there is no upper bound (i.e., unlimited). */ @CanIgnoreReturnValue public Builder setUpperBound(ResolvedExpr v) { this.upperBound = v; Preconditions.checkNotNull(v, "upperBound must not be null"); return this; } /** * If true, this quantifier is reluctant. If false, it is greedy. */ @CanIgnoreReturnValue public Builder setIsReluctant(boolean v) { this.isReluctant = v; return this; } @Override public final ResolvedMatchRecognizePatternQuantification build() { validate(); return new ResolvedMatchRecognizePatternQuantification( operand, lowerBound, upperBound, isReluctant); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( operand != null, "operand must be set"); Preconditions.checkArgument( lowerBound != null, "lowerBound must be set"); Preconditions.checkArgument( upperBound != null, "upperBound must be set"); Preconditions.checkArgument( isReluctant != null, "isReluctant must be set"); } } public static final ResolvedMatchRecognizePatternQuantification deserialize( ResolvedMatchRecognizePatternQuantificationProto proto, AbstractDeserializationHelper helper) { return new ResolvedMatchRecognizePatternQuantification(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_MATCH_RECOGNIZE_PATTERN_QUANTIFICATION; } @Override public final String nodeKindString() { return "MatchRecognizePatternQuantification"; } /** * Serializes this node into a {@link AnyResolvedMatchRecognizePatternExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedMatchRecognizePatternExprProto.Builder builder = AnyResolvedMatchRecognizePatternExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedMatchRecognizePatternExprProto.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, AnyResolvedMatchRecognizePatternExprProto.Builder builder) { builder.clear(); ResolvedMatchRecognizePatternQuantificationProto.Builder childBuilder = ResolvedMatchRecognizePatternQuantificationProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedMatchRecognizePatternQuantificationNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedMatchRecognizePatternQuantificationProto.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, ResolvedMatchRecognizePatternQuantificationProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedMatchRecognizePatternExprProto parent = (ResolvedMatchRecognizePatternExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // operand is an AST node. Call its serialization chain. if (this.getOperand() != null) { AnyResolvedMatchRecognizePatternExprProto.Builder operandBuilder = AnyResolvedMatchRecognizePatternExprProto.newBuilder(); this.getOperand().serialize( fileDescriptorSetsBuilder, operandBuilder); proto.setOperand( operandBuilder.build()); } // lowerBound is an AST node. Call its serialization chain. if (this.getLowerBound() != null) { AnyResolvedExprProto.Builder lowerBoundBuilder = AnyResolvedExprProto.newBuilder(); this.getLowerBound().serialize( fileDescriptorSetsBuilder, lowerBoundBuilder); proto.setLowerBound( lowerBoundBuilder.build()); } // upperBound is an AST node. Call its serialization chain. if (this.getUpperBound() != null) { AnyResolvedExprProto.Builder upperBoundBuilder = AnyResolvedExprProto.newBuilder(); this.getUpperBound().serialize( fileDescriptorSetsBuilder, upperBoundBuilder); proto.setUpperBound( upperBoundBuilder.build()); } // isReluctant is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsReluctant(this.getIsReluctant()); } /** * The sub-pattern to be repeated according to this quantifier. * Cannot be nullptr. */ public final ResolvedMatchRecognizePatternExpr getOperand() { return operand; } /** * Lower bound of the quantification. Cannot be nullptr. */ public final ResolvedExpr getLowerBound() { return lowerBound; } /** * The upper bound of the quantification. Can be nullptr, in which * case it means there is no upper bound (i.e., unlimited). */ public final ResolvedExpr getUpperBound() { return upperBound; } /** * If true, this quantifier is reluctant. If false, it is greedy. */ public final boolean getIsReluctant() { return isReluctant; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedMatchRecognizePatternQuantification accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(operand); visitor.descend(lowerBound); visitor.descend(upperBound); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (operand != null) { fields.add(new DebugStringField("operand", operand)); } if (lowerBound != null) { fields.add(new DebugStringField("lower_bound", lowerBound)); } if (upperBound != null) { fields.add(new DebugStringField("upper_bound", upperBound)); } { fields.add(new DebugStringField("is_reluctant", DebugStrings.toStringImpl(isReluctant))); } } } /** * CLONE DATA INTO FROM ... * *

the table to clone data into. Cannot be value table. * The source table(s) to clone data from. * For a single table, the scan is TableScan, with an optional * for_system_time_expr; * If WHERE clause is present, the Scan is wrapped inside * ResolvedFilterScan; * When multiple sources are present, they are UNION'ed together * in a ResolvedSetOperationScan. * * Constraints: * The target_table must not be the same as any source table, * and two sources cannot refer to the same table. * All source tables and target table must have equal number * of columns, with positionally identical column names and * types. * Cannot be value table. */ public static final class ResolvedCloneDataStmt extends ResolvedStatement { private final ResolvedTableScan targetTable; private final ResolvedScan cloneFrom; ResolvedCloneDataStmt(ResolvedCloneDataStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasTargetTable()) { targetTable = ResolvedTableScan.deserialize(proto.getTargetTable(), helper); } else { targetTable = null; } if (proto.hasCloneFrom()) { cloneFrom = ResolvedScan.deserialize(proto.getCloneFrom(), helper); } else { cloneFrom = null; } } ResolvedCloneDataStmt( ImmutableList hintList, ResolvedTableScan targetTable, ResolvedScan cloneFrom) { super( hintList); this.targetTable = targetTable; this.cloneFrom = cloneFrom; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.targetTable = this.getTargetTable(); builder.cloneFrom = this.getCloneFrom(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ResolvedTableScan targetTable = null; protected ResolvedScan cloneFrom = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setTargetTable(ResolvedTableScan v) { this.targetTable = v; Preconditions.checkNotNull(v, "targetTable must not be null"); return this; } @CanIgnoreReturnValue public Builder setCloneFrom(ResolvedScan v) { this.cloneFrom = v; Preconditions.checkNotNull(v, "cloneFrom must not be null"); return this; } @Override public final ResolvedCloneDataStmt build() { validate(); return new ResolvedCloneDataStmt( hintList, targetTable, cloneFrom); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( targetTable != null, "targetTable must be set"); Preconditions.checkArgument( cloneFrom != null, "cloneFrom must be set"); } } public static final ResolvedCloneDataStmt deserialize( ResolvedCloneDataStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedCloneDataStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CLONE_DATA_STMT; } @Override public final String nodeKindString() { return "CloneDataStmt"; } /** * 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(); ResolvedCloneDataStmtProto.Builder childBuilder = ResolvedCloneDataStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCloneDataStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCloneDataStmtProto.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, ResolvedCloneDataStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // targetTable is an AST node. Call its serialization chain. if (this.getTargetTable() != null) { ResolvedTableScanProto.Builder targetTableBuilder = ResolvedTableScanProto.newBuilder(); this.getTargetTable().serialize( fileDescriptorSetsBuilder, targetTableBuilder); proto.setTargetTable( targetTableBuilder.build()); } // cloneFrom is an AST node. Call its serialization chain. if (this.getCloneFrom() != null) { AnyResolvedScanProto.Builder cloneFromBuilder = AnyResolvedScanProto.newBuilder(); this.getCloneFrom().serialize( fileDescriptorSetsBuilder, cloneFromBuilder); proto.setCloneFrom( cloneFromBuilder.build()); } } public final ResolvedTableScan getTargetTable() { return targetTable; } public final ResolvedScan getCloneFrom() { return cloneFrom; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCloneDataStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(targetTable); visitor.descend(cloneFrom); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (targetTable != null) { fields.add(new DebugStringField("target_table", targetTable)); } if (cloneFrom != null) { fields.add(new DebugStringField("clone_from", cloneFrom)); } } } /** * Identifies the

and (which can be empty) that * are targets of the ANALYZE statement. * *

This list identifies the ordinals of columns to be * analyzed in the

's column list. */ public static final class ResolvedTableAndColumnInfo extends ResolvedArgument { private final Table table; private final ImmutableList columnIndexList; ResolvedTableAndColumnInfo(ResolvedTableAndColumnInfoProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); table = helper.deserialize(proto.getTable()); columnIndexList = ImmutableList.copyOf(proto.getColumnIndexListList()); } ResolvedTableAndColumnInfo( Table table, ImmutableList columnIndexList) { super(); this.table = table; this.columnIndexList = columnIndexList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.table = this.getTable(); builder.columnIndexList = this.getColumnIndexList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected Table table = null; protected ImmutableList columnIndexList = ImmutableList.of(); private Builder() {} @CanIgnoreReturnValue public Builder setTable(Table v) { this.table = v; return this; } @CanIgnoreReturnValue public Builder setColumnIndexList(List v) { this.columnIndexList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedTableAndColumnInfo build() { validate(); return new ResolvedTableAndColumnInfo( table, columnIndexList); } @Override protected void validate() { super.validate(); } } public static final ResolvedTableAndColumnInfo deserialize( ResolvedTableAndColumnInfoProto proto, AbstractDeserializationHelper helper) { return new ResolvedTableAndColumnInfo(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_TABLE_AND_COLUMN_INFO; } @Override public final String nodeKindString() { return "TableAndColumnInfo"; } /** * 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(); ResolvedTableAndColumnInfoProto.Builder childBuilder = ResolvedTableAndColumnInfoProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedTableAndColumnInfoNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedTableAndColumnInfoProto.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, ResolvedTableAndColumnInfoProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) 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)); } // 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()); } public final Table getTable() { return table; } public final ImmutableList getColumnIndexList() { return columnIndexList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedTableAndColumnInfo accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(table)) { fields.add(new DebugStringField("table", DebugStrings.toStringImpl(table))); } if (!DebugStrings.isDefaultValue(columnIndexList)) { fields.add(new DebugStringField("column_index_list", DebugStrings.toStringCommaSeparatedForInt(columnIndexList))); } } } /** * This represents the ANALYZE statement: * ANALYZE [OPTIONS ()] [ [, ...]]; * *

is a list of options for ANALYZE. * *

identifies a list of tables along with their * related columns that are the target of ANALYZE. */ public static final class ResolvedAnalyzeStmt extends ResolvedStatement { private final ImmutableList optionList; private final ImmutableList tableAndColumnIndexList; ResolvedAnalyzeStmt(ResolvedAnalyzeStmtProto proto, AbstractDeserializationHelper 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 tableAndColumnIndexListBuilder = ImmutableList.builder(); for (ResolvedTableAndColumnInfoProto element : proto.getTableAndColumnIndexListList()) { tableAndColumnIndexListBuilder .add(ResolvedTableAndColumnInfo.deserialize(element, helper)); } tableAndColumnIndexList = tableAndColumnIndexListBuilder.build(); } ResolvedAnalyzeStmt( ImmutableList hintList, ImmutableList optionList, ImmutableList tableAndColumnIndexList) { super( hintList); this.optionList = optionList; this.tableAndColumnIndexList = tableAndColumnIndexList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.optionList = this.getOptionList(); builder.tableAndColumnIndexList = this.getTableAndColumnIndexList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected ImmutableList optionList = null; protected ImmutableList tableAndColumnIndexList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setTableAndColumnIndexList(List v) { this.tableAndColumnIndexList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedAnalyzeStmt build() { validate(); return new ResolvedAnalyzeStmt( hintList, optionList, tableAndColumnIndexList); } @Override protected void validate() { super.validate(); } } public static final ResolvedAnalyzeStmt deserialize( ResolvedAnalyzeStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAnalyzeStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ANALYZE_STMT; } @Override public final String nodeKindString() { return "AnalyzeStmt"; } /** * 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(); ResolvedAnalyzeStmtProto.Builder childBuilder = ResolvedAnalyzeStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAnalyzeStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAnalyzeStmtProto.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, ResolvedAnalyzeStmtProto.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()); } // tableAndColumnIndexList is a collection of AST nodes. Serialize each of them. ImmutableList tableAndColumnIndexLists = this.getTableAndColumnIndexList(); for (ResolvedTableAndColumnInfo element : tableAndColumnIndexLists) { ResolvedTableAndColumnInfoProto.Builder tableAndColumnIndexListBuilder = ResolvedTableAndColumnInfoProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, tableAndColumnIndexListBuilder); proto.addTableAndColumnIndexList(tableAndColumnIndexListBuilder.build()); } } public final ImmutableList getOptionList() { return optionList; } public final ImmutableList getTableAndColumnIndexList() { return tableAndColumnIndexList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAnalyzeStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); visitor.descend(tableAndColumnIndexList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (!tableAndColumnIndexList.isEmpty()) { fields.add(new DebugStringField("table_and_column_index_list", tableAndColumnIndexList)); } } } /** * Indicates that the LOAD DATA statement will load to or overwrite the * selected partitions: * [OVERWRITE] PARTITIONS () */ public static final class ResolvedAuxLoadDataPartitionFilter extends ResolvedArgument { /** * Expression to find the partitions to load. * Scan rows from source file, and fail the query if filter * evaluates some rows to false. * is always of type bool. * When this expression produces NULL, the query should fail. */ private final ResolvedExpr filter; /** * Indicates whether the load data will append to or overwrite the * selected partition. */ private final boolean isOverwrite; ResolvedAuxLoadDataPartitionFilter(ResolvedAuxLoadDataPartitionFilterProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasFilter()) { filter = ResolvedExpr.deserialize(proto.getFilter(), helper); } else { filter = null; } isOverwrite = proto.getIsOverwrite(); } ResolvedAuxLoadDataPartitionFilter( ResolvedExpr filter, boolean isOverwrite) { super(); this.filter = filter; this.isOverwrite = isOverwrite; } @Override public Builder toBuilder() { Builder builder = builder(); builder.filter = this.getFilter(); builder.isOverwrite = this.getIsOverwrite(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr filter = null; protected Boolean isOverwrite = null; private Builder() {} /** * Expression to find the partitions to load. * Scan rows from source file, and fail the query if filter * evaluates some rows to false. * is always of type bool. * When this expression produces NULL, the query should fail. */ @CanIgnoreReturnValue public Builder setFilter(ResolvedExpr v) { this.filter = v; Preconditions.checkNotNull(v, "filter must not be null"); return this; } /** * Indicates whether the load data will append to or overwrite the * selected partition. */ @CanIgnoreReturnValue public Builder setIsOverwrite(boolean v) { this.isOverwrite = v; return this; } @Override public final ResolvedAuxLoadDataPartitionFilter build() { validate(); return new ResolvedAuxLoadDataPartitionFilter( filter, isOverwrite); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( filter != null, "filter must be set"); } } public static final ResolvedAuxLoadDataPartitionFilter deserialize( ResolvedAuxLoadDataPartitionFilterProto proto, AbstractDeserializationHelper helper) { return new ResolvedAuxLoadDataPartitionFilter(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_AUX_LOAD_DATA_PARTITION_FILTER; } @Override public final String nodeKindString() { return "AuxLoadDataPartitionFilter"; } /** * 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(); ResolvedAuxLoadDataPartitionFilterProto.Builder childBuilder = ResolvedAuxLoadDataPartitionFilterProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAuxLoadDataPartitionFilterNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAuxLoadDataPartitionFilterProto.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, ResolvedAuxLoadDataPartitionFilterProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // filter is an AST node. Call its serialization chain. if (this.getFilter() != null) { AnyResolvedExprProto.Builder filterBuilder = AnyResolvedExprProto.newBuilder(); this.getFilter().serialize( fileDescriptorSetsBuilder, filterBuilder); proto.setFilter( filterBuilder.build()); } // isOverwrite is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsOverwrite(this.getIsOverwrite()); } /** * Expression to find the partitions to load. * Scan rows from source file, and fail the query if filter * evaluates some rows to false. * is always of type bool. * When this expression produces NULL, the query should fail. */ public final ResolvedExpr getFilter() { return filter; } /** * Indicates whether the load data will append to or overwrite the * selected partition. */ public final boolean getIsOverwrite() { return isOverwrite; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAuxLoadDataPartitionFilter accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(filter); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (filter != null) { fields.add(new DebugStringField("filter", filter)); } if (!DebugStrings.isDefaultValue(isOverwrite)) { fields.add(new DebugStringField("is_overwrite", DebugStrings.toStringImpl(isOverwrite))); } } } /** * LOAD DATA {OVERWRITE|INTO} [{TEMP|TEMPORARY} TABLE] * [[OVERWRITE] PARTITIONS(...)] ... * FROM FILES ... * This statement loads an external file to a new or existing table. * See (broken link). * *

either OVERWRITE or APPEND (INTO) the destination table. * True if the destination table should be a temporary table. * Otherwise, the destination table should be a persistent table. * the table to load data into. * the list of visible columns of the destination table. * If is explicitly specified: * = * + * Or if the table already exists: * = .columns * Last, if the table doesn't exist and isn't * explicitly specified: * = detected-columns + * If not empty, the explicit columns of the * destination table. Must be coerciable from the source file's fields. * * When the destination table doesn't already exist, it will be created * with these columns (plus the additional columns from WITH PARTITION * COLUMNS subclause); otherwise, the destination table's schema must * match the explicit columns by both name and type. * is a list of 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. * If specified, and the table already exists, the primary_key is * required to be the same as that of the existing. * specifies the FOREIGN KEY constraints on the table. * If specified, and the table already exists, the foreign keys are * required to be the same as that of the existing. * specifies the ABSL_CHECK constraints on the table. * If specified, and the table already exists, the constraints are * required to be the same as that of the existing. * The list of columns to partition the destination * table. Similar to , it must match the * destination table's partitioning spec if it already exists. * The list of columns to cluster the destination * table. Similar to , it must match the * destination table's partitioning spec if it already exists. * specifies the destination partition selections and * whether load to or overwrite the selected partitions. * the options list describing the destination table. * If the destination doesn't already exist, it will be created with * these options; otherwise it must match the existing destination * table's options. * The columns decoded from partitioned source * files. If the destination table doesn't already exist, these columns * will be implicitly added to the destination table's schema; otherwise * the destination table must already have these columns * (matching by both names and types). * * The hive partition columns from the source file do not automatically * partition the destination table. To apply the partition, the * must be specified. * optional connection reference for accessing files. * the options list describing the source file(s). */ public static final class ResolvedAuxLoadDataStmt extends ResolvedStatement { private final InsertionMode insertionMode; private final boolean isTempTable; private final ImmutableList namePath; private final ResolvedAuxLoadDataPartitionFilter partitionFilter; private final ImmutableList outputColumnList; 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 ImmutableList optionList; private final ResolvedWithPartitionColumns withPartitionColumns; private final ResolvedConnection connection; private final ImmutableList fromFilesOptionList; ResolvedAuxLoadDataStmt(ResolvedAuxLoadDataStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); insertionMode = proto.getInsertionMode(); isTempTable = proto.getIsTempTable(); namePath = ImmutableList.copyOf(proto.getNamePathList()); if (proto.hasPartitionFilter()) { partitionFilter = ResolvedAuxLoadDataPartitionFilter.deserialize(proto.getPartitionFilter(), helper); } else { partitionFilter = null; } ImmutableList.Builder outputColumnListBuilder = ImmutableList.builder(); for (ResolvedOutputColumnProto element : proto.getOutputColumnListList()) { outputColumnListBuilder .add(ResolvedOutputColumn.deserialize(element, helper)); } outputColumnList = outputColumnListBuilder.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(); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); if (proto.hasWithPartitionColumns()) { withPartitionColumns = ResolvedWithPartitionColumns.deserialize(proto.getWithPartitionColumns(), helper); } else { withPartitionColumns = null; } if (proto.hasConnection()) { connection = ResolvedConnection.deserialize(proto.getConnection(), helper); } else { connection = null; } ImmutableList.Builder fromFilesOptionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getFromFilesOptionListList()) { fromFilesOptionListBuilder .add(ResolvedOption.deserialize(element, helper)); } fromFilesOptionList = fromFilesOptionListBuilder.build(); } ResolvedAuxLoadDataStmt( ImmutableList hintList, InsertionMode insertionMode, boolean isTempTable, ImmutableList namePath, ResolvedAuxLoadDataPartitionFilter partitionFilter, ImmutableList outputColumnList, ImmutableList columnDefinitionList, ImmutableList pseudoColumnList, ResolvedPrimaryKey primaryKey, ImmutableList foreignKeyList, ImmutableList checkConstraintList, ImmutableList partitionByList, ImmutableList clusterByList, ImmutableList optionList, ResolvedWithPartitionColumns withPartitionColumns, ResolvedConnection connection, ImmutableList fromFilesOptionList) { super( hintList); this.insertionMode = insertionMode; this.isTempTable = isTempTable; this.namePath = namePath; this.partitionFilter = partitionFilter; this.outputColumnList = outputColumnList; this.columnDefinitionList = columnDefinitionList; this.pseudoColumnList = pseudoColumnList; this.primaryKey = primaryKey; this.foreignKeyList = foreignKeyList; this.checkConstraintList = checkConstraintList; this.partitionByList = partitionByList; this.clusterByList = clusterByList; this.optionList = optionList; this.withPartitionColumns = withPartitionColumns; this.connection = connection; this.fromFilesOptionList = fromFilesOptionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.insertionMode = this.getInsertionMode(); builder.isTempTable = this.getIsTempTable(); builder.namePath = this.getNamePath(); builder.partitionFilter = this.getPartitionFilter(); builder.outputColumnList = this.getOutputColumnList(); builder.columnDefinitionList = this.getColumnDefinitionList(); builder.pseudoColumnList = this.getPseudoColumnList(); builder.primaryKey = this.getPrimaryKey(); builder.foreignKeyList = this.getForeignKeyList(); builder.checkConstraintList = this.getCheckConstraintList(); builder.partitionByList = this.getPartitionByList(); builder.clusterByList = this.getClusterByList(); builder.optionList = this.getOptionList(); builder.withPartitionColumns = this.getWithPartitionColumns(); builder.connection = this.getConnection(); builder.fromFilesOptionList = this.getFromFilesOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected InsertionMode insertionMode = null; protected Boolean isTempTable = null; protected ImmutableList namePath = null; protected ResolvedAuxLoadDataPartitionFilter partitionFilter = null; protected ImmutableList outputColumnList = null; protected ImmutableList columnDefinitionList = null; protected ImmutableList pseudoColumnList = null; protected ResolvedPrimaryKey primaryKey = null; protected ImmutableList foreignKeyList = null; protected ImmutableList checkConstraintList = null; protected ImmutableList partitionByList = null; protected ImmutableList clusterByList = null; protected ImmutableList optionList = null; protected ResolvedWithPartitionColumns withPartitionColumns = null; protected ResolvedConnection connection = null; protected ImmutableList fromFilesOptionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setInsertionMode(InsertionMode v) { this.insertionMode = v; Preconditions.checkNotNull(v, "insertionMode must not be null"); return this; } @CanIgnoreReturnValue public Builder setIsTempTable(boolean v) { this.isTempTable = v; return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setPartitionFilter(ResolvedAuxLoadDataPartitionFilter v) { this.partitionFilter = v; return this; } @CanIgnoreReturnValue public Builder setOutputColumnList(List v) { this.outputColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setColumnDefinitionList(List v) { this.columnDefinitionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setPseudoColumnList(List v) { this.pseudoColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setPrimaryKey(ResolvedPrimaryKey v) { this.primaryKey = v; return this; } @CanIgnoreReturnValue public Builder setForeignKeyList(List v) { this.foreignKeyList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setCheckConstraintList(List v) { this.checkConstraintList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setPartitionByList(List v) { this.partitionByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setClusterByList(List v) { this.clusterByList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setWithPartitionColumns(ResolvedWithPartitionColumns v) { this.withPartitionColumns = v; return this; } @CanIgnoreReturnValue public Builder setConnection(ResolvedConnection v) { this.connection = v; return this; } @CanIgnoreReturnValue public Builder setFromFilesOptionList(List v) { this.fromFilesOptionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedAuxLoadDataStmt build() { validate(); return new ResolvedAuxLoadDataStmt( hintList, insertionMode, isTempTable, namePath, partitionFilter, outputColumnList, columnDefinitionList, pseudoColumnList, primaryKey, foreignKeyList, checkConstraintList, partitionByList, clusterByList, optionList, withPartitionColumns, connection, fromFilesOptionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( insertionMode != null, "insertionMode must be set"); Preconditions.checkArgument( isTempTable != null, "isTempTable must be set"); } } public static final ResolvedAuxLoadDataStmt deserialize( ResolvedAuxLoadDataStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAuxLoadDataStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_AUX_LOAD_DATA_STMT; } @Override public final String nodeKindString() { return "AuxLoadDataStmt"; } /** * 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(); ResolvedAuxLoadDataStmtProto.Builder childBuilder = ResolvedAuxLoadDataStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAuxLoadDataStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAuxLoadDataStmtProto.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, ResolvedAuxLoadDataStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // insertionMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setInsertionMode(this.getInsertionMode()); // isTempTable is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsTempTable(this.getIsTempTable()); // 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()); // partitionFilter is an AST node. Call its serialization chain. if (this.getPartitionFilter() != null) { ResolvedAuxLoadDataPartitionFilterProto.Builder partitionFilterBuilder = ResolvedAuxLoadDataPartitionFilterProto.newBuilder(); this.getPartitionFilter().serialize( fileDescriptorSetsBuilder, partitionFilterBuilder); proto.setPartitionFilter( partitionFilterBuilder.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()); } // 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()); } // 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()); } // withPartitionColumns is an AST node. Call its serialization chain. if (this.getWithPartitionColumns() != null) { ResolvedWithPartitionColumnsProto.Builder withPartitionColumnsBuilder = ResolvedWithPartitionColumnsProto.newBuilder(); this.getWithPartitionColumns().serialize( fileDescriptorSetsBuilder, withPartitionColumnsBuilder); proto.setWithPartitionColumns( withPartitionColumnsBuilder.build()); } // connection is an AST node. Call its serialization chain. if (this.getConnection() != null) { ResolvedConnectionProto.Builder connectionBuilder = ResolvedConnectionProto.newBuilder(); this.getConnection().serialize( fileDescriptorSetsBuilder, connectionBuilder); proto.setConnection( connectionBuilder.build()); } // fromFilesOptionList is a collection of AST nodes. Serialize each of them. ImmutableList fromFilesOptionLists = this.getFromFilesOptionList(); for (ResolvedOption element : fromFilesOptionLists) { ResolvedOptionProto.Builder fromFilesOptionListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, fromFilesOptionListBuilder); proto.addFromFilesOptionList(fromFilesOptionListBuilder.build()); } } public final InsertionMode getInsertionMode() { return insertionMode; } public final boolean getIsTempTable() { return isTempTable; } public final ImmutableList getNamePath() { return namePath; } public final ResolvedAuxLoadDataPartitionFilter getPartitionFilter() { return partitionFilter; } public final ImmutableList getOutputColumnList() { return outputColumnList; } 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 ImmutableList getOptionList() { return optionList; } public final ResolvedWithPartitionColumns getWithPartitionColumns() { return withPartitionColumns; } public final ResolvedConnection getConnection() { return connection; } public final ImmutableList getFromFilesOptionList() { return fromFilesOptionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAuxLoadDataStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(partitionFilter); visitor.descend(outputColumnList); visitor.descend(columnDefinitionList); visitor.descend(primaryKey); visitor.descend(foreignKeyList); visitor.descend(checkConstraintList); visitor.descend(partitionByList); visitor.descend(clusterByList); visitor.descend(optionList); visitor.descend(withPartitionColumns); visitor.descend(connection); visitor.descend(fromFilesOptionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("insertion_mode", DebugStrings.toStringImpl(insertionMode))); } { fields.add(new DebugStringField("is_temp_table", DebugStrings.toStringImpl(isTempTable))); } if (!DebugStrings.isDefaultValue(namePath)) { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (partitionFilter != null) { fields.add(new DebugStringField("partition_filter", partitionFilter)); } if (!outputColumnList.isEmpty()) { fields.add(new DebugStringField("output_column_list", outputColumnList)); } 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 (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } if (withPartitionColumns != null) { fields.add(new DebugStringField("with_partition_columns", withPartitionColumns)); } if (connection != null) { fields.add(new DebugStringField("connection", connection)); } if (!fromFilesOptionList.isEmpty()) { fields.add(new DebugStringField("from_files_option_list", fromFilesOptionList)); } } } /** * This statement: * CREATE [OR REPLACE] PROPERTY GRAPH [IF NOT EXISTS] * [OPTIONS ()] * NODE TABLES() * [EDGE TABLES()] * *

is a placeholder for engine-specific directives. * has the list of node table definitions. * has the list of edge table definitions. */ public static final class ResolvedCreatePropertyGraphStmt extends ResolvedCreateStatement { private final ImmutableList nodeTableList; private final ImmutableList edgeTableList; /** * All labels defined in this property graph. */ private final ImmutableList labelList; /** * All property declarations exposed by labels in this property * graph. */ private final ImmutableList propertyDeclarationList; private final ImmutableList optionList; ResolvedCreatePropertyGraphStmt(ResolvedCreatePropertyGraphStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder nodeTableListBuilder = ImmutableList.builder(); for (ResolvedGraphElementTableProto element : proto.getNodeTableListList()) { nodeTableListBuilder .add(ResolvedGraphElementTable.deserialize(element, helper)); } nodeTableList = nodeTableListBuilder.build(); ImmutableList.Builder edgeTableListBuilder = ImmutableList.builder(); for (ResolvedGraphElementTableProto element : proto.getEdgeTableListList()) { edgeTableListBuilder .add(ResolvedGraphElementTable.deserialize(element, helper)); } edgeTableList = edgeTableListBuilder.build(); ImmutableList.Builder labelListBuilder = ImmutableList.builder(); for (ResolvedGraphElementLabelProto element : proto.getLabelListList()) { labelListBuilder .add(ResolvedGraphElementLabel.deserialize(element, helper)); } labelList = labelListBuilder.build(); ImmutableList.Builder propertyDeclarationListBuilder = ImmutableList.builder(); for (ResolvedGraphPropertyDeclarationProto element : proto.getPropertyDeclarationListList()) { propertyDeclarationListBuilder .add(ResolvedGraphPropertyDeclaration.deserialize(element, helper)); } propertyDeclarationList = propertyDeclarationListBuilder.build(); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedCreatePropertyGraphStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList nodeTableList, ImmutableList edgeTableList, ImmutableList labelList, ImmutableList propertyDeclarationList, ImmutableList optionList) { super( hintList, namePath, createScope, createMode); this.nodeTableList = nodeTableList; this.edgeTableList = edgeTableList; this.labelList = labelList; this.propertyDeclarationList = propertyDeclarationList; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.nodeTableList = this.getNodeTableList(); builder.edgeTableList = this.getEdgeTableList(); builder.labelList = this.getLabelList(); builder.propertyDeclarationList = this.getPropertyDeclarationList(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList nodeTableList = null; protected ImmutableList edgeTableList = ImmutableList.of(); protected ImmutableList labelList = null; protected ImmutableList propertyDeclarationList = null; protected ImmutableList optionList = ImmutableList.of(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setNodeTableList(List v) { this.nodeTableList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setEdgeTableList(List v) { this.edgeTableList = ImmutableList.copyOf(v); return this; } /** * All labels defined in this property graph. */ @CanIgnoreReturnValue public Builder setLabelList(List v) { this.labelList = ImmutableList.copyOf(v); return this; } /** * All property declarations exposed by labels in this property * graph. */ @CanIgnoreReturnValue public Builder setPropertyDeclarationList(List v) { this.propertyDeclarationList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCreatePropertyGraphStmt build() { validate(); return new ResolvedCreatePropertyGraphStmt( hintList, namePath, createScope, createMode, nodeTableList, edgeTableList, labelList, propertyDeclarationList, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( nodeTableList != null, "nodeTableList must be set"); Preconditions.checkArgument( labelList != null, "labelList must be set"); Preconditions.checkArgument( propertyDeclarationList != null, "propertyDeclarationList must be set"); } } public static final ResolvedCreatePropertyGraphStmt deserialize( ResolvedCreatePropertyGraphStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedCreatePropertyGraphStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_PROPERTY_GRAPH_STMT; } @Override public final String nodeKindString() { return "CreatePropertyGraphStmt"; } /** * 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(); ResolvedCreatePropertyGraphStmtProto.Builder childBuilder = ResolvedCreatePropertyGraphStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreatePropertyGraphStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreatePropertyGraphStmtProto.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, ResolvedCreatePropertyGraphStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedCreateStatementProto parent = (ResolvedCreateStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // nodeTableList is a collection of AST nodes. Serialize each of them. ImmutableList nodeTableLists = this.getNodeTableList(); for (ResolvedGraphElementTable element : nodeTableLists) { ResolvedGraphElementTableProto.Builder nodeTableListBuilder = ResolvedGraphElementTableProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, nodeTableListBuilder); proto.addNodeTableList(nodeTableListBuilder.build()); } // edgeTableList is a collection of AST nodes. Serialize each of them. ImmutableList edgeTableLists = this.getEdgeTableList(); for (ResolvedGraphElementTable element : edgeTableLists) { ResolvedGraphElementTableProto.Builder edgeTableListBuilder = ResolvedGraphElementTableProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, edgeTableListBuilder); proto.addEdgeTableList(edgeTableListBuilder.build()); } // labelList is a collection of AST nodes. Serialize each of them. ImmutableList labelLists = this.getLabelList(); for (ResolvedGraphElementLabel element : labelLists) { ResolvedGraphElementLabelProto.Builder labelListBuilder = ResolvedGraphElementLabelProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, labelListBuilder); proto.addLabelList(labelListBuilder.build()); } // propertyDeclarationList is a collection of AST nodes. Serialize each of them. ImmutableList propertyDeclarationLists = this.getPropertyDeclarationList(); for (ResolvedGraphPropertyDeclaration element : propertyDeclarationLists) { ResolvedGraphPropertyDeclarationProto.Builder propertyDeclarationListBuilder = ResolvedGraphPropertyDeclarationProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, propertyDeclarationListBuilder); proto.addPropertyDeclarationList(propertyDeclarationListBuilder.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()); } } public final ImmutableList getNodeTableList() { return nodeTableList; } public final ImmutableList getEdgeTableList() { return edgeTableList; } /** * All labels defined in this property graph. */ public final ImmutableList getLabelList() { return labelList; } /** * All property declarations exposed by labels in this property * graph. */ public final ImmutableList getPropertyDeclarationList() { return propertyDeclarationList; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedCreatePropertyGraphStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(nodeTableList); visitor.descend(edgeTableList); visitor.descend(labelList); visitor.descend(propertyDeclarationList); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!nodeTableList.isEmpty()) { fields.add(new DebugStringField("node_table_list", nodeTableList)); } if (!edgeTableList.isEmpty()) { fields.add(new DebugStringField("edge_table_list", edgeTableList)); } if (!labelList.isEmpty()) { fields.add(new DebugStringField("label_list", labelList)); } if (!propertyDeclarationList.isEmpty()) { fields.add(new DebugStringField("property_declaration_list", propertyDeclarationList)); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * GraphElementTable definition: * [AS ] * [KEY()] * [] * [] * [] * [ identifier of the element table in the property graph. * has a set of references to ResolvedColumn from input_scan that * can uniquely identify rows in the element table. * describes how rows in edge table connect to * rows in the referenced source node table. * describes how rows in edge table connect to * rows in the referenced destination node table by same value columns. * is a list of label names. * is a list of property definitions exposed by * labels. */ public static final class ResolvedGraphElementTable extends ResolvedArgument { private final String alias; /** * ResolvedScan of the underlying table, view etc for column * references in key_list and source/dest_node_reference. */ private final ResolvedScan inputScan; private final ImmutableList keyList; private final ResolvedGraphNodeTableReference sourceNodeReference; private final ResolvedGraphNodeTableReference destNodeReference; private final ImmutableList labelNameList; private final ImmutableList propertyDefinitionList; ResolvedGraphElementTable(ResolvedGraphElementTableProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); alias = proto.getAlias(); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } ImmutableList.Builder keyListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getKeyListList()) { keyListBuilder .add(ResolvedExpr.deserialize(element, helper)); } keyList = keyListBuilder.build(); if (proto.hasSourceNodeReference()) { sourceNodeReference = ResolvedGraphNodeTableReference.deserialize(proto.getSourceNodeReference(), helper); } else { sourceNodeReference = null; } if (proto.hasDestNodeReference()) { destNodeReference = ResolvedGraphNodeTableReference.deserialize(proto.getDestNodeReference(), helper); } else { destNodeReference = null; } labelNameList = ImmutableList.copyOf(proto.getLabelNameListList()); ImmutableList.Builder propertyDefinitionListBuilder = ImmutableList.builder(); for (ResolvedGraphPropertyDefinitionProto element : proto.getPropertyDefinitionListList()) { propertyDefinitionListBuilder .add(ResolvedGraphPropertyDefinition.deserialize(element, helper)); } propertyDefinitionList = propertyDefinitionListBuilder.build(); } ResolvedGraphElementTable( String alias, ResolvedScan inputScan, ImmutableList keyList, ResolvedGraphNodeTableReference sourceNodeReference, ResolvedGraphNodeTableReference destNodeReference, ImmutableList labelNameList, ImmutableList propertyDefinitionList) { super(); this.alias = alias; this.inputScan = inputScan; this.keyList = keyList; this.sourceNodeReference = sourceNodeReference; this.destNodeReference = destNodeReference; this.labelNameList = labelNameList; this.propertyDefinitionList = propertyDefinitionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.alias = this.getAlias(); builder.inputScan = this.getInputScan(); builder.keyList = this.getKeyList(); builder.sourceNodeReference = this.getSourceNodeReference(); builder.destNodeReference = this.getDestNodeReference(); builder.labelNameList = this.getLabelNameList(); builder.propertyDefinitionList = this.getPropertyDefinitionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String alias = null; protected ResolvedScan inputScan = null; protected ImmutableList keyList = null; protected ResolvedGraphNodeTableReference sourceNodeReference = null; protected ResolvedGraphNodeTableReference destNodeReference = null; protected ImmutableList labelNameList = null; protected ImmutableList propertyDefinitionList = ImmutableList.of(); private Builder() {} @CanIgnoreReturnValue public Builder setAlias(String v) { this.alias = v; Preconditions.checkNotNull(v, "alias must not be null"); return this; } /** * ResolvedScan of the underlying table, view etc for column * references in key_list and source/dest_node_reference. */ @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setKeyList(List v) { this.keyList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setSourceNodeReference(ResolvedGraphNodeTableReference v) { this.sourceNodeReference = v; return this; } @CanIgnoreReturnValue public Builder setDestNodeReference(ResolvedGraphNodeTableReference v) { this.destNodeReference = v; return this; } @CanIgnoreReturnValue public Builder setLabelNameList(List v) { this.labelNameList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setPropertyDefinitionList(List v) { this.propertyDefinitionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGraphElementTable build() { validate(); return new ResolvedGraphElementTable( alias, inputScan, keyList, sourceNodeReference, destNodeReference, labelNameList, propertyDefinitionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( alias != null, "alias must be set"); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( keyList != null, "keyList must be set"); Preconditions.checkArgument( labelNameList != null, "labelNameList must be set"); } } public static final ResolvedGraphElementTable deserialize( ResolvedGraphElementTableProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphElementTable(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_ELEMENT_TABLE; } @Override public final String nodeKindString() { return "GraphElementTable"; } /** * 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(); ResolvedGraphElementTableProto.Builder childBuilder = ResolvedGraphElementTableProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphElementTableNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphElementTableProto.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, ResolvedGraphElementTableProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // 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()); // 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()); } // keyList is a collection of AST nodes. Serialize each of them. ImmutableList keyLists = this.getKeyList(); for (ResolvedExpr element : keyLists) { AnyResolvedExprProto.Builder keyListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, keyListBuilder); proto.addKeyList(keyListBuilder.build()); } // sourceNodeReference is an AST node. Call its serialization chain. if (this.getSourceNodeReference() != null) { ResolvedGraphNodeTableReferenceProto.Builder sourceNodeReferenceBuilder = ResolvedGraphNodeTableReferenceProto.newBuilder(); this.getSourceNodeReference().serialize( fileDescriptorSetsBuilder, sourceNodeReferenceBuilder); proto.setSourceNodeReference( sourceNodeReferenceBuilder.build()); } // destNodeReference is an AST node. Call its serialization chain. if (this.getDestNodeReference() != null) { ResolvedGraphNodeTableReferenceProto.Builder destNodeReferenceBuilder = ResolvedGraphNodeTableReferenceProto.newBuilder(); this.getDestNodeReference().serialize( fileDescriptorSetsBuilder, destNodeReferenceBuilder); proto.setDestNodeReference( destNodeReferenceBuilder.build()); } // labelNameList 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.addAllLabelNameList(this.getLabelNameList()); // propertyDefinitionList is a collection of AST nodes. Serialize each of them. ImmutableList propertyDefinitionLists = this.getPropertyDefinitionList(); for (ResolvedGraphPropertyDefinition element : propertyDefinitionLists) { ResolvedGraphPropertyDefinitionProto.Builder propertyDefinitionListBuilder = ResolvedGraphPropertyDefinitionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, propertyDefinitionListBuilder); proto.addPropertyDefinitionList(propertyDefinitionListBuilder.build()); } } public final String getAlias() { return alias; } /** * ResolvedScan of the underlying table, view etc for column * references in key_list and source/dest_node_reference. */ public final ResolvedScan getInputScan() { return inputScan; } public final ImmutableList getKeyList() { return keyList; } public final ResolvedGraphNodeTableReference getSourceNodeReference() { return sourceNodeReference; } public final ResolvedGraphNodeTableReference getDestNodeReference() { return destNodeReference; } public final ImmutableList getLabelNameList() { return labelNameList; } public final ImmutableList getPropertyDefinitionList() { return propertyDefinitionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphElementTable accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(keyList); visitor.descend(sourceNodeReference); visitor.descend(destNodeReference); visitor.descend(propertyDefinitionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("alias", DebugStrings.toStringImpl(alias))); } if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (!keyList.isEmpty()) { fields.add(new DebugStringField("key_list", keyList)); } if (sourceNodeReference != null) { fields.add(new DebugStringField("source_node_reference", sourceNodeReference)); } if (destNodeReference != null) { fields.add(new DebugStringField("dest_node_reference", destNodeReference)); } { fields.add(new DebugStringField("label_name_list", DebugStrings.toStringCommaSeparated(labelNameList))); } if (!propertyDefinitionList.isEmpty()) { fields.add(new DebugStringField("property_definition_list", propertyDefinitionList)); } } } /** * GraphNodeTableReference definition: * SOURCE|DESTINATION KEY() REFERENCES * () * *

must be a defined node table's alias. * contains columns from the edge table referencing * corresponding node table columns at the same ordinal position in * . */ public static final class ResolvedGraphNodeTableReference extends ResolvedArgument { private final String nodeTableIdentifier; private final ImmutableList edgeTableColumnList; private final ImmutableList nodeTableColumnList; ResolvedGraphNodeTableReference(ResolvedGraphNodeTableReferenceProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); nodeTableIdentifier = proto.getNodeTableIdentifier(); ImmutableList.Builder edgeTableColumnListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getEdgeTableColumnListList()) { edgeTableColumnListBuilder .add(ResolvedExpr.deserialize(element, helper)); } edgeTableColumnList = edgeTableColumnListBuilder.build(); ImmutableList.Builder nodeTableColumnListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getNodeTableColumnListList()) { nodeTableColumnListBuilder .add(ResolvedExpr.deserialize(element, helper)); } nodeTableColumnList = nodeTableColumnListBuilder.build(); } ResolvedGraphNodeTableReference( String nodeTableIdentifier, ImmutableList edgeTableColumnList, ImmutableList nodeTableColumnList) { super(); this.nodeTableIdentifier = nodeTableIdentifier; this.edgeTableColumnList = edgeTableColumnList; this.nodeTableColumnList = nodeTableColumnList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.nodeTableIdentifier = this.getNodeTableIdentifier(); builder.edgeTableColumnList = this.getEdgeTableColumnList(); builder.nodeTableColumnList = this.getNodeTableColumnList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String nodeTableIdentifier = null; protected ImmutableList edgeTableColumnList = null; protected ImmutableList nodeTableColumnList = ImmutableList.of(); private Builder() {} @CanIgnoreReturnValue public Builder setNodeTableIdentifier(String v) { this.nodeTableIdentifier = v; Preconditions.checkNotNull(v, "nodeTableIdentifier must not be null"); return this; } @CanIgnoreReturnValue public Builder setEdgeTableColumnList(List v) { this.edgeTableColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setNodeTableColumnList(List v) { this.nodeTableColumnList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGraphNodeTableReference build() { validate(); return new ResolvedGraphNodeTableReference( nodeTableIdentifier, edgeTableColumnList, nodeTableColumnList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( nodeTableIdentifier != null, "nodeTableIdentifier must be set"); Preconditions.checkArgument( edgeTableColumnList != null, "edgeTableColumnList must be set"); } } public static final ResolvedGraphNodeTableReference deserialize( ResolvedGraphNodeTableReferenceProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphNodeTableReference(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_NODE_TABLE_REFERENCE; } @Override public final String nodeKindString() { return "GraphNodeTableReference"; } /** * 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(); ResolvedGraphNodeTableReferenceProto.Builder childBuilder = ResolvedGraphNodeTableReferenceProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphNodeTableReferenceNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphNodeTableReferenceProto.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, ResolvedGraphNodeTableReferenceProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // nodeTableIdentifier is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setNodeTableIdentifier(this.getNodeTableIdentifier()); // edgeTableColumnList is a collection of AST nodes. Serialize each of them. ImmutableList edgeTableColumnLists = this.getEdgeTableColumnList(); for (ResolvedExpr element : edgeTableColumnLists) { AnyResolvedExprProto.Builder edgeTableColumnListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, edgeTableColumnListBuilder); proto.addEdgeTableColumnList(edgeTableColumnListBuilder.build()); } // nodeTableColumnList is a collection of AST nodes. Serialize each of them. ImmutableList nodeTableColumnLists = this.getNodeTableColumnList(); for (ResolvedExpr element : nodeTableColumnLists) { AnyResolvedExprProto.Builder nodeTableColumnListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, nodeTableColumnListBuilder); proto.addNodeTableColumnList(nodeTableColumnListBuilder.build()); } } public final String getNodeTableIdentifier() { return nodeTableIdentifier; } public final ImmutableList getEdgeTableColumnList() { return edgeTableColumnList; } public final ImmutableList getNodeTableColumnList() { return nodeTableColumnList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphNodeTableReference accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(edgeTableColumnList); visitor.descend(nodeTableColumnList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("node_table_identifier", DebugStrings.toStringImpl(nodeTableIdentifier))); } if (!edgeTableColumnList.isEmpty()) { fields.add(new DebugStringField("edge_table_column_list", edgeTableColumnList)); } if (!nodeTableColumnList.isEmpty()) { fields.add(new DebugStringField("node_table_column_list", nodeTableColumnList)); } } } /** * is the name of the label. * is a list of property declarations * exposed by the label. */ public static final class ResolvedGraphElementLabel extends ResolvedArgument { private final String name; private final ImmutableList propertyDeclarationNameList; ResolvedGraphElementLabel(ResolvedGraphElementLabelProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); propertyDeclarationNameList = ImmutableList.copyOf(proto.getPropertyDeclarationNameListList()); } ResolvedGraphElementLabel( String name, ImmutableList propertyDeclarationNameList) { super(); this.name = name; this.propertyDeclarationNameList = propertyDeclarationNameList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.name = this.getName(); builder.propertyDeclarationNameList = this.getPropertyDeclarationNameList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String name = null; protected ImmutableList propertyDeclarationNameList = ImmutableList.of(); private Builder() {} @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setPropertyDeclarationNameList(List v) { this.propertyDeclarationNameList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGraphElementLabel build() { validate(); return new ResolvedGraphElementLabel( name, propertyDeclarationNameList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); } } public static final ResolvedGraphElementLabel deserialize( ResolvedGraphElementLabelProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphElementLabel(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_ELEMENT_LABEL; } @Override public final String nodeKindString() { return "GraphElementLabel"; } /** * 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(); ResolvedGraphElementLabelProto.Builder childBuilder = ResolvedGraphElementLabelProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphElementLabelNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphElementLabelProto.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, ResolvedGraphElementLabelProto.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()); // propertyDeclarationNameList 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.addAllPropertyDeclarationNameList(this.getPropertyDeclarationNameList()); } public final String getName() { return name; } public final ImmutableList getPropertyDeclarationNameList() { return propertyDeclarationNameList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphElementLabel accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } if (!DebugStrings.isDefaultValue(propertyDeclarationNameList)) { fields.add(new DebugStringField("property_declaration_name_list", DebugStrings.toStringCommaSeparated(propertyDeclarationNameList))); } } } /** * Represents a property name and type exposed by a GraphElementLabel. */ public static final class ResolvedGraphPropertyDeclaration extends ResolvedArgument { private final String name; private final Type type; ResolvedGraphPropertyDeclaration(ResolvedGraphPropertyDeclarationProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); name = proto.getName(); type = helper.deserialize(proto.getType()); } ResolvedGraphPropertyDeclaration( String name, Type type) { super(); this.name = name; this.type = type; } @Override public Builder toBuilder() { Builder builder = builder(); builder.name = this.getName(); builder.type = this.getType(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected String name = null; protected Type type = null; private Builder() {} @CanIgnoreReturnValue public Builder setName(String v) { this.name = v; Preconditions.checkNotNull(v, "name must not be null"); return this; } @CanIgnoreReturnValue public Builder setType(Type v) { this.type = v; Preconditions.checkNotNull(v, "type must not be null"); return this; } @Override public final ResolvedGraphPropertyDeclaration build() { validate(); return new ResolvedGraphPropertyDeclaration( name, type); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( name != null, "name must be set"); Preconditions.checkArgument( type != null, "type must be set"); } } public static final ResolvedGraphPropertyDeclaration deserialize( ResolvedGraphPropertyDeclarationProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphPropertyDeclaration(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_PROPERTY_DECLARATION; } @Override public final String nodeKindString() { return "GraphPropertyDeclaration"; } /** * 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(); ResolvedGraphPropertyDeclarationProto.Builder childBuilder = ResolvedGraphPropertyDeclarationProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphPropertyDeclarationNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphPropertyDeclarationProto.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, ResolvedGraphPropertyDeclarationProto.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)); } } public final String getName() { return name; } public final Type getType() { return type; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphPropertyDeclaration accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("name", DebugStrings.toStringImpl(name))); } { fields.add(new DebugStringField("type", DebugStrings.toStringImpl(type))); } } } /** * Represents a property exposed by a GraphElementLabel on a specific * GraphElementTable. * [ AS ] * *

is the property definition, a ResolvedExpression to identify a * column. * is the original sql string of the property definition. * refers to a property declaration. */ public static final class ResolvedGraphPropertyDefinition extends ResolvedArgument { private final ResolvedExpr expr; private final String sql; private final String propertyDeclarationName; ResolvedGraphPropertyDefinition(ResolvedGraphPropertyDefinitionProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } sql = proto.getSql(); propertyDeclarationName = proto.getPropertyDeclarationName(); } ResolvedGraphPropertyDefinition( ResolvedExpr expr, String sql, String propertyDeclarationName) { super(); this.expr = expr; this.sql = sql; this.propertyDeclarationName = propertyDeclarationName; } @Override public Builder toBuilder() { Builder builder = builder(); builder.expr = this.getExpr(); builder.sql = this.getSql(); builder.propertyDeclarationName = this.getPropertyDeclarationName(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr expr = null; protected String sql = null; protected String propertyDeclarationName = null; private Builder() {} @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @CanIgnoreReturnValue public Builder setSql(String v) { this.sql = v; Preconditions.checkNotNull(v, "sql must not be null"); return this; } @CanIgnoreReturnValue public Builder setPropertyDeclarationName(String v) { this.propertyDeclarationName = v; Preconditions.checkNotNull(v, "propertyDeclarationName must not be null"); return this; } @Override public final ResolvedGraphPropertyDefinition build() { validate(); return new ResolvedGraphPropertyDefinition( expr, sql, propertyDeclarationName); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( sql != null, "sql must be set"); Preconditions.checkArgument( propertyDeclarationName != null, "propertyDeclarationName must be set"); } } public static final ResolvedGraphPropertyDefinition deserialize( ResolvedGraphPropertyDefinitionProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphPropertyDefinition(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_PROPERTY_DEFINITION; } @Override public final String nodeKindString() { return "GraphPropertyDefinition"; } /** * 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(); ResolvedGraphPropertyDefinitionProto.Builder childBuilder = ResolvedGraphPropertyDefinitionProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphPropertyDefinitionNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphPropertyDefinitionProto.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, ResolvedGraphPropertyDefinitionProto.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()); } // 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()); // propertyDeclarationName is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setPropertyDeclarationName(this.getPropertyDeclarationName()); } public final ResolvedExpr getExpr() { return expr; } public final String getSql() { return sql; } public final String getPropertyDeclarationName() { return propertyDeclarationName; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphPropertyDefinition accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } { fields.add(new DebugStringField("sql", DebugStrings.toStringImpl(sql))); } { fields.add(new DebugStringField("property_declaration_name", DebugStrings.toStringImpl(propertyDeclarationName))); } } } /** * Base scan class for graph scans */ public static abstract class ResolvedGraphScanBase extends ResolvedScan { ResolvedGraphScanBase(ResolvedGraphScanBaseProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedGraphScanBase( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource) { super( columnList, hintList, isOrdered, nodeSource); } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedScan.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override public abstract ResolvedGraphScanBase build(); @Override protected void validate() { super.validate(); } } public static ResolvedGraphScanBase deserialize( AnyResolvedGraphScanBaseProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_GRAPH_SCAN_NODE: return ResolvedGraphScan.deserialize( proto.getResolvedGraphScanNode(), helper); case RESOLVED_GRAPH_LINEAR_SCAN_NODE: return ResolvedGraphLinearScan.deserialize( proto.getResolvedGraphLinearScanNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedGraphScanBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedGraphScanBaseProto.Builder builder = ResolvedGraphScanBaseProto.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(); AnyResolvedGraphScanBaseProto.Builder childBuilder = AnyResolvedGraphScanBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphScanBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedGraphScanBaseProto.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, AnyResolvedGraphScanBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedGraphScanBaseProto.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, ResolvedGraphScanBaseProto.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 abstract ResolvedGraphScanBase accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * A reference scan that can be used as input by a scan op * to its previous scan op within the same parent GraphLinearScan. */ public static final class ResolvedGraphRefScan extends ResolvedScan { ResolvedGraphRefScan(ResolvedGraphRefScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedGraphRefScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource) { super( columnList, hintList, isOrdered, nodeSource); } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override public final ResolvedGraphRefScan build() { validate(); return new ResolvedGraphRefScan( columnList, hintList, isOrdered, nodeSource); } @Override protected void validate() { super.validate(); } } public static final ResolvedGraphRefScan deserialize( ResolvedGraphRefScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphRefScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_REF_SCAN; } @Override public final String nodeKindString() { return "GraphRefScan"; } /** * 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(); ResolvedGraphRefScanProto.Builder childBuilder = ResolvedGraphRefScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphRefScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphRefScanProto.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, ResolvedGraphRefScanProto.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 public ResolvedGraphRefScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * GraphLinearScan consists of multiple child scans executed in * order and outputs the last scan */ public static final class ResolvedGraphLinearScan extends ResolvedGraphScanBase { private final ImmutableList scanList; ResolvedGraphLinearScan(ResolvedGraphLinearScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder scanListBuilder = ImmutableList.builder(); for (AnyResolvedScanProto element : proto.getScanListList()) { scanListBuilder .add(ResolvedScan.deserialize(element, helper)); } scanList = scanListBuilder.build(); } ResolvedGraphLinearScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ImmutableList scanList) { super( columnList, hintList, isOrdered, nodeSource); this.scanList = scanList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.scanList = this.getScanList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGraphScanBase.Builder { protected ImmutableList scanList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setScanList(List v) { this.scanList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGraphLinearScan build() { validate(); return new ResolvedGraphLinearScan( columnList, hintList, isOrdered, nodeSource, scanList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( scanList != null, "scanList must be set"); } } public static final ResolvedGraphLinearScan deserialize( ResolvedGraphLinearScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphLinearScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_LINEAR_SCAN; } @Override public final String nodeKindString() { return "GraphLinearScan"; } /** * Serializes this node into a {@link AnyResolvedGraphScanBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGraphScanBaseProto.Builder builder = AnyResolvedGraphScanBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGraphScanBaseProto.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, AnyResolvedGraphScanBaseProto.Builder builder) { builder.clear(); ResolvedGraphLinearScanProto.Builder childBuilder = ResolvedGraphLinearScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphLinearScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphLinearScanProto.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, ResolvedGraphLinearScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGraphScanBaseProto parent = (ResolvedGraphScanBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // scanList is a collection of AST nodes. Serialize each of them. ImmutableList scanLists = this.getScanList(); for (ResolvedScan element : scanLists) { AnyResolvedScanProto.Builder scanListBuilder = AnyResolvedScanProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, scanListBuilder); proto.addScanList(scanListBuilder.build()); } } public final ImmutableList getScanList() { return scanList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphLinearScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(scanList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!scanList.isEmpty()) { fields.add(new DebugStringField("scan_list", scanList)); } } } /** * A scan produced by as described in * (broken link):graph-table-syntax, or gql enabled , * as described in (broken link):gql-graph-table. * *

It produces columns of non-graph SQL type, either defined by * or from directly. * When FEATURE_V_1_4_SQL_GRAPH_EXPOSE_GRAPH_ELEMENT is enabled it may * produce columns of graph element type. * *

If is not empty, it defines the output columns of * ResolvedGraphTableScan, it can only access columns produced from * . */ public static final class ResolvedGraphTableScan extends ResolvedScan { private final PropertyGraph propertyGraph; private final ResolvedGraphScanBase inputScan; private final ImmutableList shapeExprList; ResolvedGraphTableScan(ResolvedGraphTableScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); propertyGraph = helper.deserialize(proto.getPropertyGraph()); if (proto.hasInputScan()) { inputScan = ResolvedGraphScanBase.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } ImmutableList.Builder shapeExprListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getShapeExprListList()) { shapeExprListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } shapeExprList = shapeExprListBuilder.build(); } ResolvedGraphTableScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, PropertyGraph propertyGraph, ResolvedGraphScanBase inputScan, ImmutableList shapeExprList) { super( columnList, hintList, isOrdered, nodeSource); this.propertyGraph = propertyGraph; this.inputScan = inputScan; this.shapeExprList = shapeExprList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.propertyGraph = this.getPropertyGraph(); builder.inputScan = this.getInputScan(); builder.shapeExprList = this.getShapeExprList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected PropertyGraph propertyGraph = null; protected ResolvedGraphScanBase inputScan = null; protected ImmutableList shapeExprList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setPropertyGraph(PropertyGraph v) { this.propertyGraph = v; Preconditions.checkNotNull(v, "propertyGraph must not be null"); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedGraphScanBase v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setShapeExprList(List v) { this.shapeExprList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGraphTableScan build() { validate(); return new ResolvedGraphTableScan( columnList, hintList, isOrdered, nodeSource, propertyGraph, inputScan, shapeExprList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( propertyGraph != null, "propertyGraph must be set"); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( shapeExprList != null, "shapeExprList must be set"); } } public static final ResolvedGraphTableScan deserialize( ResolvedGraphTableScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphTableScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_TABLE_SCAN; } @Override public final String nodeKindString() { return "GraphTableScan"; } /** * 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(); ResolvedGraphTableScanProto.Builder childBuilder = ResolvedGraphTableScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphTableScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphTableScanProto.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, ResolvedGraphTableScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedScanProto parent = (ResolvedScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // propertyGraph is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getPropertyGraph() != null) { proto.setPropertyGraph( ResolvedNodes.serialize(this.getPropertyGraph(), fileDescriptorSetsBuilder)); } // inputScan is an AST node. Call its serialization chain. if (this.getInputScan() != null) { AnyResolvedGraphScanBaseProto.Builder inputScanBuilder = AnyResolvedGraphScanBaseProto.newBuilder(); this.getInputScan().serialize( fileDescriptorSetsBuilder, inputScanBuilder); proto.setInputScan( inputScanBuilder.build()); } // shapeExprList is a collection of AST nodes. Serialize each of them. ImmutableList shapeExprLists = this.getShapeExprList(); for (ResolvedComputedColumn element : shapeExprLists) { ResolvedComputedColumnProto.Builder shapeExprListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, shapeExprListBuilder); proto.addShapeExprList(shapeExprListBuilder.build()); } } public final PropertyGraph getPropertyGraph() { return propertyGraph; } public final ResolvedGraphScanBase getInputScan() { return inputScan; } public final ImmutableList getShapeExprList() { return shapeExprList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphTableScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(shapeExprList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("property_graph", DebugStrings.toStringImpl(propertyGraph))); } if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (!shapeExprList.isEmpty()) { fields.add(new DebugStringField("shape_expr_list", shapeExprList)); } } } /** * A scan produced by a in . It represents the * cross product of input ResolvedGraphPathScans, each represents a matching * sequences of graph elements (i.e. paths) in the property graph. * *

The will contain columns from the s of the * input path scans. * *

contains expressions resolved from * graph pattern where clause, and possible equalities for joining path scans * on multiply-declared variables. It further filters the set of matched * paths. * *

When exists, the natural join semantics mentioned in * (broken link):gql-linear-comp would be applied to the scan and * this . * *

When is true and exists, LEFT OUTER JOIN semantics * mentioned in (broken link):optional-match would be applied to and * scan produced from . */ public static final class ResolvedGraphScan extends ResolvedGraphScanBase { /** * path pattern list contained in the graph pattern */ private final ImmutableList inputScanList; private final ResolvedExpr filterExpr; /** * current tabular result in the graph query to be joined with. * See (broken link):gql-linear-comp for more details. This can only be a * ResolvedGraphRefScan after resolution, and would become a * ProjectScan / other GraphScan when linear query is rewritten into * a nested tree structure. */ private final ResolvedScan inputScan; /** * this is the result of an OPTIONAL MATCH. See * (broken link):optional-match for more details. Corresponds to a left * outer join. */ private final boolean optional; ResolvedGraphScan(ResolvedGraphScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder inputScanListBuilder = ImmutableList.builder(); for (ResolvedGraphPathScanProto element : proto.getInputScanListList()) { inputScanListBuilder .add(ResolvedGraphPathScan.deserialize(element, helper)); } inputScanList = inputScanListBuilder.build(); if (proto.hasFilterExpr()) { filterExpr = ResolvedExpr.deserialize(proto.getFilterExpr(), helper); } else { filterExpr = null; } if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } optional = proto.getOptional(); } ResolvedGraphScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ImmutableList inputScanList, ResolvedExpr filterExpr, ResolvedScan inputScan, boolean optional) { super( columnList, hintList, isOrdered, nodeSource); this.inputScanList = inputScanList; this.filterExpr = filterExpr; this.inputScan = inputScan; this.optional = optional; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScanList = this.getInputScanList(); builder.filterExpr = this.getFilterExpr(); builder.inputScan = this.getInputScan(); builder.optional = this.getOptional(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGraphScanBase.Builder { protected ImmutableList inputScanList = null; protected ResolvedExpr filterExpr = null; protected ResolvedScan inputScan = null; protected boolean optional = false; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } /** * path pattern list contained in the graph pattern */ @CanIgnoreReturnValue public Builder setInputScanList(List v) { this.inputScanList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setFilterExpr(ResolvedExpr v) { this.filterExpr = v; return this; } /** * current tabular result in the graph query to be joined with. * See (broken link):gql-linear-comp for more details. This can only be a * ResolvedGraphRefScan after resolution, and would become a * ProjectScan / other GraphScan when linear query is rewritten into * a nested tree structure. */ @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; return this; } /** * this is the result of an OPTIONAL MATCH. See * (broken link):optional-match for more details. Corresponds to a left * outer join. */ @CanIgnoreReturnValue public Builder setOptional(boolean v) { this.optional = v; return this; } @Override public final ResolvedGraphScan build() { validate(); return new ResolvedGraphScan( columnList, hintList, isOrdered, nodeSource, inputScanList, filterExpr, inputScan, optional); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScanList != null, "inputScanList must be set"); } } public static final ResolvedGraphScan deserialize( ResolvedGraphScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_SCAN; } @Override public final String nodeKindString() { return "GraphScan"; } /** * Serializes this node into a {@link AnyResolvedGraphScanBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGraphScanBaseProto.Builder builder = AnyResolvedGraphScanBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGraphScanBaseProto.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, AnyResolvedGraphScanBaseProto.Builder builder) { builder.clear(); ResolvedGraphScanProto.Builder childBuilder = ResolvedGraphScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphScanProto.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, ResolvedGraphScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGraphScanBaseProto parent = (ResolvedGraphScanBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputScanList is a collection of AST nodes. Serialize each of them. ImmutableList inputScanLists = this.getInputScanList(); for (ResolvedGraphPathScan element : inputScanLists) { ResolvedGraphPathScanProto.Builder inputScanListBuilder = ResolvedGraphPathScanProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, inputScanListBuilder); proto.addInputScanList(inputScanListBuilder.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()); } // 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()); } // optional is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setOptional(this.getOptional()); } /** * path pattern list contained in the graph pattern */ public final ImmutableList getInputScanList() { return inputScanList; } public final ResolvedExpr getFilterExpr() { return filterExpr; } /** * current tabular result in the graph query to be joined with. * See (broken link):gql-linear-comp for more details. This can only be a * ResolvedGraphRefScan after resolution, and would become a * ProjectScan / other GraphScan when linear query is rewritten into * a nested tree structure. */ public final ResolvedScan getInputScan() { return inputScan; } /** * this is the result of an OPTIONAL MATCH. See * (broken link):optional-match for more details. Corresponds to a left * outer join. */ public final boolean getOptional() { return optional; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScanList); visitor.descend(filterExpr); visitor.descend(inputScan); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!inputScanList.isEmpty()) { fields.add(new DebugStringField("input_scan_list", inputScanList)); } if (filterExpr != null) { fields.add(new DebugStringField("filter_expr", filterExpr)); } if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (!DebugStrings.isDefaultValue(optional)) { fields.add(new DebugStringField("optional", DebugStrings.toStringImpl(optional))); } } } /** * A graph path pattern quantifier is used to represent the repetition of * a path pattern. */ public static final class ResolvedGraphPathPatternQuantifier extends ResolvedArgument { private final ResolvedExpr lowerBound; private final ResolvedExpr upperBound; ResolvedGraphPathPatternQuantifier(ResolvedGraphPathPatternQuantifierProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasLowerBound()) { lowerBound = ResolvedExpr.deserialize(proto.getLowerBound(), helper); } else { lowerBound = null; } if (proto.hasUpperBound()) { upperBound = ResolvedExpr.deserialize(proto.getUpperBound(), helper); } else { upperBound = null; } } ResolvedGraphPathPatternQuantifier( ResolvedExpr lowerBound, ResolvedExpr upperBound) { super(); this.lowerBound = lowerBound; this.upperBound = upperBound; } @Override public Builder toBuilder() { Builder builder = builder(); builder.lowerBound = this.getLowerBound(); builder.upperBound = this.getUpperBound(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr lowerBound = null; protected ResolvedExpr upperBound = null; private Builder() {} @CanIgnoreReturnValue public Builder setLowerBound(ResolvedExpr v) { this.lowerBound = v; Preconditions.checkNotNull(v, "lowerBound must not be null"); return this; } @CanIgnoreReturnValue public Builder setUpperBound(ResolvedExpr v) { this.upperBound = v; Preconditions.checkNotNull(v, "upperBound must not be null"); return this; } @Override public final ResolvedGraphPathPatternQuantifier build() { validate(); return new ResolvedGraphPathPatternQuantifier( lowerBound, upperBound); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( lowerBound != null, "lowerBound must be set"); Preconditions.checkArgument( upperBound != null, "upperBound must be set"); } } public static final ResolvedGraphPathPatternQuantifier deserialize( ResolvedGraphPathPatternQuantifierProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphPathPatternQuantifier(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_PATH_PATTERN_QUANTIFIER; } @Override public final String nodeKindString() { return "GraphPathPatternQuantifier"; } /** * 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(); ResolvedGraphPathPatternQuantifierProto.Builder childBuilder = ResolvedGraphPathPatternQuantifierProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphPathPatternQuantifierNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphPathPatternQuantifierProto.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, ResolvedGraphPathPatternQuantifierProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // lowerBound is an AST node. Call its serialization chain. if (this.getLowerBound() != null) { AnyResolvedExprProto.Builder lowerBoundBuilder = AnyResolvedExprProto.newBuilder(); this.getLowerBound().serialize( fileDescriptorSetsBuilder, lowerBoundBuilder); proto.setLowerBound( lowerBoundBuilder.build()); } // upperBound is an AST node. Call its serialization chain. if (this.getUpperBound() != null) { AnyResolvedExprProto.Builder upperBoundBuilder = AnyResolvedExprProto.newBuilder(); this.getUpperBound().serialize( fileDescriptorSetsBuilder, upperBoundBuilder); proto.setUpperBound( upperBoundBuilder.build()); } } public final ResolvedExpr getLowerBound() { return lowerBound; } public final ResolvedExpr getUpperBound() { return upperBound; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphPathPatternQuantifier accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(lowerBound); visitor.descend(upperBound); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (lowerBound != null) { fields.add(new DebugStringField("lower_bound", lowerBound)); } if (upperBound != null) { fields.add(new DebugStringField("upper_bound", upperBound)); } } } /** * A graph path pattern search prefix, which restricts the result from a * graph pattern match by grouping the resulting paths by their * endpoints (the first and last vertices) and makes a selection of * paths from each group. */ public static final class ResolvedGraphPathSearchPrefix extends ResolvedArgument { private final PathSearchPrefixType type; ResolvedGraphPathSearchPrefix(ResolvedGraphPathSearchPrefixProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); type = proto.getType(); } ResolvedGraphPathSearchPrefix( PathSearchPrefixType type) { super(); this.type = type; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected PathSearchPrefixType type = null; private Builder() {} @CanIgnoreReturnValue public Builder setType(PathSearchPrefixType v) { this.type = v; Preconditions.checkNotNull(v, "type must not be null"); return this; } @Override public final ResolvedGraphPathSearchPrefix build() { validate(); return new ResolvedGraphPathSearchPrefix( type); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( type != null, "type must be set"); } } public static final ResolvedGraphPathSearchPrefix deserialize( ResolvedGraphPathSearchPrefixProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphPathSearchPrefix(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_PATH_SEARCH_PREFIX; } @Override public final String nodeKindString() { return "GraphPathSearchPrefix"; } /** * 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(); ResolvedGraphPathSearchPrefixProto.Builder childBuilder = ResolvedGraphPathSearchPrefixProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphPathSearchPrefixNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphPathSearchPrefixProto.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, ResolvedGraphPathSearchPrefixProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // type is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setType(this.getType()); } public final PathSearchPrefixType getType() { return type; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphPathSearchPrefix accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("type", DebugStrings.toStringImpl(type))); } } } /** * Common base class for path scan and element scan. * This is needed to support parenthesized path pattern. */ public static abstract class ResolvedGraphPathScanBase extends ResolvedScan { ResolvedGraphPathScanBase(ResolvedGraphPathScanBaseProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedGraphPathScanBase( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource) { super( columnList, hintList, isOrdered, nodeSource); } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedScan.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override public abstract ResolvedGraphPathScanBase build(); @Override protected void validate() { super.validate(); } } public static ResolvedGraphPathScanBase deserialize( AnyResolvedGraphPathScanBaseProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_GRAPH_ELEMENT_SCAN_NODE: return ResolvedGraphElementScan.deserialize( proto.getResolvedGraphElementScanNode(), helper); case RESOLVED_GRAPH_PATH_SCAN_NODE: return ResolvedGraphPathScan.deserialize( proto.getResolvedGraphPathScanNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedGraphPathScanBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedGraphPathScanBaseProto.Builder builder = ResolvedGraphPathScanBaseProto.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(); AnyResolvedGraphPathScanBaseProto.Builder childBuilder = AnyResolvedGraphPathScanBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphPathScanBaseNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedGraphPathScanBaseProto.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, AnyResolvedGraphPathScanBaseProto.Builder builder); /** * Serializes this node into the given {@link ResolvedGraphPathScanBaseProto.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, ResolvedGraphPathScanBaseProto.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 abstract ResolvedGraphPathScanBase accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * A base scan produced by a . * Outputs a stream of single-columned rows where evaluates * to true and is satisfied. Column is of * GraphElementType(kind=Node|Edge). * Element tables matching the label expression and the element kind * are accessible in . */ public static abstract class ResolvedGraphElementScan extends ResolvedGraphPathScanBase { private final ResolvedExpr filterExpr; /** * This is a logical combination of individual labels belonging * to a property graph using conjunctions (&), disjunctions (|), * negations (!), and grouping parentheses. During query evaluation, * relevant graph element tables are retrieved that satisfy * . */ private final ResolvedGraphLabelExpr labelExpr; /** * This is a vector of element tables of kind Node or Edge that * were found to satisfy during resolution. */ private final ImmutableList targetElementTableList; ResolvedGraphElementScan(ResolvedGraphElementScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasFilterExpr()) { filterExpr = ResolvedExpr.deserialize(proto.getFilterExpr(), helper); } else { filterExpr = null; } if (proto.hasLabelExpr()) { labelExpr = ResolvedGraphLabelExpr.deserialize(proto.getLabelExpr(), helper); } else { labelExpr = null; } ImmutableList.Builder targetElementTableListBuilder = ImmutableList.builder(); for (GraphElementTableRefProto element : proto.getTargetElementTableListList()) { targetElementTableListBuilder.add(helper.deserialize(element)); } targetElementTableList = targetElementTableListBuilder.build(); } ResolvedGraphElementScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedExpr filterExpr, ResolvedGraphLabelExpr labelExpr, ImmutableList targetElementTableList) { super( columnList, hintList, isOrdered, nodeSource); this.filterExpr = filterExpr; this.labelExpr = labelExpr; this.targetElementTableList = targetElementTableList; } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedGraphPathScanBase.Builder { protected ResolvedExpr filterExpr = null; protected ResolvedGraphLabelExpr labelExpr = null; protected ImmutableList targetElementTableList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setFilterExpr(ResolvedExpr v) { this.filterExpr = v; Preconditions.checkNotNull(v, "filterExpr must not be null"); return this; } /** * This is a logical combination of individual labels belonging * to a property graph using conjunctions (&), disjunctions (|), * negations (!), and grouping parentheses. During query evaluation, * relevant graph element tables are retrieved that satisfy * . */ @CanIgnoreReturnValue public Builder setLabelExpr(ResolvedGraphLabelExpr v) { this.labelExpr = v; Preconditions.checkNotNull(v, "labelExpr must not be null"); return this; } /** * This is a vector of element tables of kind Node or Edge that * were found to satisfy during resolution. */ @CanIgnoreReturnValue public Builder setTargetElementTableList(List v) { this.targetElementTableList = ImmutableList.copyOf(v); return this; } @Override public abstract ResolvedGraphElementScan build(); @Override protected void validate() { super.validate(); Preconditions.checkArgument( filterExpr != null, "filterExpr must be set"); Preconditions.checkArgument( labelExpr != null, "labelExpr must be set"); Preconditions.checkArgument( targetElementTableList != null, "targetElementTableList must be set"); } } public static ResolvedGraphElementScan deserialize( AnyResolvedGraphElementScanProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_GRAPH_NODE_SCAN_NODE: return ResolvedGraphNodeScan.deserialize( proto.getResolvedGraphNodeScanNode(), helper); case RESOLVED_GRAPH_EDGE_SCAN_NODE: return ResolvedGraphEdgeScan.deserialize( proto.getResolvedGraphEdgeScanNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedGraphElementScanProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedGraphElementScanProto.Builder builder = ResolvedGraphElementScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGraphPathScanBaseProto.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, AnyResolvedGraphPathScanBaseProto.Builder builder) { builder.clear(); AnyResolvedGraphElementScanProto.Builder childBuilder = AnyResolvedGraphElementScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphElementScanNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedGraphElementScanProto.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, AnyResolvedGraphElementScanProto.Builder builder); /** * Serializes this node into the given {@link ResolvedGraphElementScanProto.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, ResolvedGraphElementScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGraphPathScanBaseProto parent = (ResolvedGraphPathScanBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // 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()); } // labelExpr is an AST node. Call its serialization chain. if (this.getLabelExpr() != null) { AnyResolvedGraphLabelExprProto.Builder labelExprBuilder = AnyResolvedGraphLabelExprProto.newBuilder(); this.getLabelExpr().serialize( fileDescriptorSetsBuilder, labelExprBuilder); proto.setLabelExpr( labelExprBuilder.build()); } // targetElementTableList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList targetElementTableLists = this.getTargetElementTableList(); for (GraphElementTable element : targetElementTableLists) { proto.addTargetElementTableList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } } public final ResolvedExpr getFilterExpr() { return filterExpr; } /** * This is a logical combination of individual labels belonging * to a property graph using conjunctions (&), disjunctions (|), * negations (!), and grouping parentheses. During query evaluation, * relevant graph element tables are retrieved that satisfy * . */ public final ResolvedGraphLabelExpr getLabelExpr() { return labelExpr; } /** * This is a vector of element tables of kind Node or Edge that * were found to satisfy during resolution. */ public final ImmutableList getTargetElementTableList() { return targetElementTableList; } @Override public abstract ResolvedGraphElementScan accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(filterExpr); visitor.descend(labelExpr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (filterExpr != null) { fields.add(new DebugStringField("filter_expr", filterExpr)); } if (labelExpr != null) { fields.add(new DebugStringField("label_expr", labelExpr)); } { fields.add(new DebugStringField("target_element_table_list", DebugStrings.toStringCommaSeparatedForGraphElementTable(targetElementTableList))); } } } /** * A ResolvedGraphElementScan produced by , whose the single * output column is of GraphElementType(kind=Node). */ public static final class ResolvedGraphNodeScan extends ResolvedGraphElementScan { ResolvedGraphNodeScan(ResolvedGraphNodeScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedGraphNodeScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedExpr filterExpr, ResolvedGraphLabelExpr labelExpr, ImmutableList targetElementTableList) { super( columnList, hintList, isOrdered, nodeSource, filterExpr, labelExpr, targetElementTableList); } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.filterExpr = this.getFilterExpr(); builder.labelExpr = this.getLabelExpr(); builder.targetElementTableList = this.getTargetElementTableList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGraphElementScan.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override @CanIgnoreReturnValue public Builder setFilterExpr(ResolvedExpr v) { super.setFilterExpr(v); return this; } @Override @CanIgnoreReturnValue public Builder setLabelExpr(ResolvedGraphLabelExpr v) { super.setLabelExpr(v); return this; } @Override @CanIgnoreReturnValue public Builder setTargetElementTableList(List v) { super.setTargetElementTableList(v); return this; } @Override public final ResolvedGraphNodeScan build() { validate(); return new ResolvedGraphNodeScan( columnList, hintList, isOrdered, nodeSource, filterExpr, labelExpr, targetElementTableList); } @Override protected void validate() { super.validate(); } } public static final ResolvedGraphNodeScan deserialize( ResolvedGraphNodeScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphNodeScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_NODE_SCAN; } @Override public final String nodeKindString() { return "GraphNodeScan"; } /** * Serializes this node into a {@link AnyResolvedGraphElementScanProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGraphElementScanProto.Builder builder = AnyResolvedGraphElementScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGraphElementScanProto.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, AnyResolvedGraphElementScanProto.Builder builder) { builder.clear(); ResolvedGraphNodeScanProto.Builder childBuilder = ResolvedGraphNodeScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphNodeScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphNodeScanProto.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, ResolvedGraphNodeScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGraphElementScanProto parent = (ResolvedGraphElementScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphNodeScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * A ResolvedGraphElementScan produced by , whose the single * output column is of GraphElementType(kind=Edge). * *

The edge scan also specifies the orientation requirement: only edges * matches the orientation should be returned. */ public static final class ResolvedGraphEdgeScan extends ResolvedGraphElementScan { private final EdgeOrientation orientation; private final ImmutableList lhsHintList; private final ImmutableList rhsHintList; ResolvedGraphEdgeScan(ResolvedGraphEdgeScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); orientation = proto.getOrientation(); ImmutableList.Builder lhsHintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getLhsHintListList()) { lhsHintListBuilder .add(ResolvedOption.deserialize(element, helper)); } lhsHintList = lhsHintListBuilder.build(); ImmutableList.Builder rhsHintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getRhsHintListList()) { rhsHintListBuilder .add(ResolvedOption.deserialize(element, helper)); } rhsHintList = rhsHintListBuilder.build(); } ResolvedGraphEdgeScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedExpr filterExpr, ResolvedGraphLabelExpr labelExpr, ImmutableList targetElementTableList, EdgeOrientation orientation, ImmutableList lhsHintList, ImmutableList rhsHintList) { super( columnList, hintList, isOrdered, nodeSource, filterExpr, labelExpr, targetElementTableList); this.orientation = orientation; this.lhsHintList = lhsHintList; this.rhsHintList = rhsHintList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.filterExpr = this.getFilterExpr(); builder.labelExpr = this.getLabelExpr(); builder.targetElementTableList = this.getTargetElementTableList(); builder.orientation = this.getOrientation(); builder.lhsHintList = this.getLhsHintList(); builder.rhsHintList = this.getRhsHintList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGraphElementScan.Builder { protected EdgeOrientation orientation = null; protected ImmutableList lhsHintList = ImmutableList.of(); protected ImmutableList rhsHintList = ImmutableList.of(); private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override @CanIgnoreReturnValue public Builder setFilterExpr(ResolvedExpr v) { super.setFilterExpr(v); return this; } @Override @CanIgnoreReturnValue public Builder setLabelExpr(ResolvedGraphLabelExpr v) { super.setLabelExpr(v); return this; } @Override @CanIgnoreReturnValue public Builder setTargetElementTableList(List v) { super.setTargetElementTableList(v); return this; } @CanIgnoreReturnValue public Builder setOrientation(EdgeOrientation v) { this.orientation = v; Preconditions.checkNotNull(v, "orientation must not be null"); return this; } @CanIgnoreReturnValue public Builder setLhsHintList(List v) { this.lhsHintList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setRhsHintList(List v) { this.rhsHintList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGraphEdgeScan build() { validate(); return new ResolvedGraphEdgeScan( columnList, hintList, isOrdered, nodeSource, filterExpr, labelExpr, targetElementTableList, orientation, lhsHintList, rhsHintList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( orientation != null, "orientation must be set"); } } public static final ResolvedGraphEdgeScan deserialize( ResolvedGraphEdgeScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphEdgeScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_EDGE_SCAN; } @Override public final String nodeKindString() { return "GraphEdgeScan"; } /** * Serializes this node into a {@link AnyResolvedGraphElementScanProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGraphElementScanProto.Builder builder = AnyResolvedGraphElementScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGraphElementScanProto.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, AnyResolvedGraphElementScanProto.Builder builder) { builder.clear(); ResolvedGraphEdgeScanProto.Builder childBuilder = ResolvedGraphEdgeScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphEdgeScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphEdgeScanProto.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, ResolvedGraphEdgeScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGraphElementScanProto parent = (ResolvedGraphElementScanProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // orientation is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setOrientation(this.getOrientation()); // lhsHintList is a collection of AST nodes. Serialize each of them. ImmutableList lhsHintLists = this.getLhsHintList(); for (ResolvedOption element : lhsHintLists) { ResolvedOptionProto.Builder lhsHintListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, lhsHintListBuilder); proto.addLhsHintList(lhsHintListBuilder.build()); } // rhsHintList is a collection of AST nodes. Serialize each of them. ImmutableList rhsHintLists = this.getRhsHintList(); for (ResolvedOption element : rhsHintLists) { ResolvedOptionProto.Builder rhsHintListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, rhsHintListBuilder); proto.addRhsHintList(rhsHintListBuilder.build()); } } public final EdgeOrientation getOrientation() { return orientation; } public final ImmutableList getLhsHintList() { return lhsHintList; } public final ImmutableList getRhsHintList() { return rhsHintList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphEdgeScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(lhsHintList); visitor.descend(rhsHintList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("orientation", DebugStrings.toStringImpl(orientation))); } if (!lhsHintList.isEmpty()) { fields.add(new DebugStringField("lhs_hint_list", lhsHintList)); } if (!rhsHintList.isEmpty()) { fields.add(new DebugStringField("rhs_hint_list", rhsHintList)); } } } /** * Get property from the graph element in . must * be of GraphElementType. */ public static final class ResolvedGraphGetElementProperty extends ResolvedExpr { private final ResolvedExpr expr; private final GraphPropertyDeclaration property; ResolvedGraphGetElementProperty(ResolvedGraphGetElementPropertyProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } property = helper.deserialize(proto.getProperty()); } ResolvedGraphGetElementProperty( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr expr, GraphPropertyDeclaration property) { super( type, typeAnnotationMap); this.expr = expr; this.property = property; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.expr = this.getExpr(); builder.property = this.getProperty(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr expr = null; protected GraphPropertyDeclaration property = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @CanIgnoreReturnValue public Builder setProperty(GraphPropertyDeclaration v) { this.property = v; Preconditions.checkNotNull(v, "property must not be null"); return this; } @Override public final ResolvedGraphGetElementProperty build() { validate(); return new ResolvedGraphGetElementProperty( type, typeAnnotationMap, expr, property); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( property != null, "property must be set"); } } public static final ResolvedGraphGetElementProperty deserialize( ResolvedGraphGetElementPropertyProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphGetElementProperty(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_GET_ELEMENT_PROPERTY; } @Override public final String nodeKindString() { return "GraphGetElementProperty"; } /** * 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(); ResolvedGraphGetElementPropertyProto.Builder childBuilder = ResolvedGraphGetElementPropertyProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphGetElementPropertyNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphGetElementPropertyProto.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, ResolvedGraphGetElementPropertyProto.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()); } // property is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getProperty() != null) { proto.setProperty( ResolvedNodes.serialize(this.getProperty(), fileDescriptorSetsBuilder)); } } public final ResolvedExpr getExpr() { return expr; } public final GraphPropertyDeclaration getProperty() { return property; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphGetElementProperty accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (expr != null) { fields.add(new DebugStringField("expr", expr)); } { fields.add(new DebugStringField("property", DebugStrings.toStringImpl(property))); } } } /** * A label is an element of a graph that declares what properties * are exposed by some node/edge table. * A label expression is an arbitrarily complex expression of labels with the * operators &, |, and ! as well as grouping parentheses. */ public static abstract class ResolvedGraphLabelExpr extends ResolvedArgument { ResolvedGraphLabelExpr(ResolvedGraphLabelExprProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedGraphLabelExpr() { super(); } @Override public abstract Builder toBuilder(); public static abstract class Builder extends ResolvedArgument.Builder { private Builder() {} @Override public abstract ResolvedGraphLabelExpr build(); @Override protected void validate() { super.validate(); } } public static ResolvedGraphLabelExpr deserialize( AnyResolvedGraphLabelExprProto proto, AbstractDeserializationHelper helper) { switch (proto.getNodeCase()) { case RESOLVED_GRAPH_LABEL_NARY_EXPR_NODE: return ResolvedGraphLabelNaryExpr.deserialize( proto.getResolvedGraphLabelNaryExprNode(), helper); case RESOLVED_GRAPH_LABEL_NODE: return ResolvedGraphLabel.deserialize( proto.getResolvedGraphLabelNode(), helper); case RESOLVED_GRAPH_WILD_CARD_LABEL_NODE: return ResolvedGraphWildCardLabel.deserialize( proto.getResolvedGraphWildCardLabelNode(), helper); default: throw new IllegalArgumentException("Invalid Node kind: " + proto.getNodeCase()); } } /** * Serializes this node into a {@link ResolvedGraphLabelExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { ResolvedGraphLabelExprProto.Builder builder = ResolvedGraphLabelExprProto.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(); AnyResolvedGraphLabelExprProto.Builder childBuilder = AnyResolvedGraphLabelExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphLabelExprNode(childBuilder.build()); } /** * Serializes this node into the appropriate field type proto builder * ({@link AnyResolvedGraphLabelExprProto.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, AnyResolvedGraphLabelExprProto.Builder builder); /** * Serializes this node into the given {@link ResolvedGraphLabelExprProto.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, ResolvedGraphLabelExprProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public abstract ResolvedGraphLabelExpr accept(RewritingVisitor visitor); @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This represents a logical operation performed on a set of individual * labels, where specifies the type of operation (&, |, !) and * contains the operands of type ResolvedGraphLabelExpr. Note * that & and | are N-ary instead of binary to flatten the expressions * and avoid deep stacks. Note that ! is unary and therefore expects * that has 1 element. */ public static final class ResolvedGraphLabelNaryExpr extends ResolvedGraphLabelExpr { private final GraphLogicalOpType op; private final ImmutableList operandList; ResolvedGraphLabelNaryExpr(ResolvedGraphLabelNaryExprProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); op = proto.getOp(); ImmutableList.Builder operandListBuilder = ImmutableList.builder(); for (AnyResolvedGraphLabelExprProto element : proto.getOperandListList()) { operandListBuilder .add(ResolvedGraphLabelExpr.deserialize(element, helper)); } operandList = operandListBuilder.build(); } ResolvedGraphLabelNaryExpr( GraphLogicalOpType op, ImmutableList operandList) { super(); this.op = op; this.operandList = operandList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.op = this.getOp(); builder.operandList = this.getOperandList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGraphLabelExpr.Builder { protected GraphLogicalOpType op = null; protected ImmutableList operandList = null; private Builder() {} @CanIgnoreReturnValue public Builder setOp(GraphLogicalOpType v) { this.op = v; Preconditions.checkNotNull(v, "op must not be null"); return this; } @CanIgnoreReturnValue public Builder setOperandList(List v) { this.operandList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGraphLabelNaryExpr build() { validate(); return new ResolvedGraphLabelNaryExpr( op, operandList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( op != null, "op must be set"); } } public static final ResolvedGraphLabelNaryExpr deserialize( ResolvedGraphLabelNaryExprProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphLabelNaryExpr(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_LABEL_NARY_EXPR; } @Override public final String nodeKindString() { return "GraphLabelNaryExpr"; } /** * Serializes this node into a {@link AnyResolvedGraphLabelExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGraphLabelExprProto.Builder builder = AnyResolvedGraphLabelExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGraphLabelExprProto.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, AnyResolvedGraphLabelExprProto.Builder builder) { builder.clear(); ResolvedGraphLabelNaryExprProto.Builder childBuilder = ResolvedGraphLabelNaryExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphLabelNaryExprNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphLabelNaryExprProto.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, ResolvedGraphLabelNaryExprProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGraphLabelExprProto parent = (ResolvedGraphLabelExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // op is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setOp(this.getOp()); // operandList is a collection of AST nodes. Serialize each of them. ImmutableList operandLists = this.getOperandList(); for (ResolvedGraphLabelExpr element : operandLists) { AnyResolvedGraphLabelExprProto.Builder operandListBuilder = AnyResolvedGraphLabelExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, operandListBuilder); proto.addOperandList(operandListBuilder.build()); } } public final GraphLogicalOpType getOp() { return op; } public final ImmutableList getOperandList() { return operandList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphLabelNaryExpr accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(operandList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("op", DebugStrings.toStringImpl(op))); } if (!operandList.isEmpty()) { fields.add(new DebugStringField("operand_list", operandList)); } } } /** * This represents a single resolved graph label. A label is an element * belonging to a property graph that has a unique name identifier and * references a set of property declarations. An element table with * a given label exposes all the properties declared by that label. */ public static final class ResolvedGraphLabel extends ResolvedGraphLabelExpr { /** * Points to a label in the catalog */ private final GraphElementLabel label; ResolvedGraphLabel(ResolvedGraphLabelProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); label = helper.deserialize(proto.getLabel()); } ResolvedGraphLabel( GraphElementLabel label) { super(); this.label = label; } @Override public Builder toBuilder() { Builder builder = builder(); builder.label = this.getLabel(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGraphLabelExpr.Builder { protected GraphElementLabel label = null; private Builder() {} /** * Points to a label in the catalog */ @CanIgnoreReturnValue public Builder setLabel(GraphElementLabel v) { this.label = v; Preconditions.checkNotNull(v, "label must not be null"); return this; } @Override public final ResolvedGraphLabel build() { validate(); return new ResolvedGraphLabel( label); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( label != null, "label must be set"); } } public static final ResolvedGraphLabel deserialize( ResolvedGraphLabelProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphLabel(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_LABEL; } @Override public final String nodeKindString() { return "GraphLabel"; } /** * Serializes this node into a {@link AnyResolvedGraphLabelExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGraphLabelExprProto.Builder builder = AnyResolvedGraphLabelExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGraphLabelExprProto.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, AnyResolvedGraphLabelExprProto.Builder builder) { builder.clear(); ResolvedGraphLabelProto.Builder childBuilder = ResolvedGraphLabelProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphLabelNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphLabelProto.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, ResolvedGraphLabelProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGraphLabelExprProto parent = (ResolvedGraphLabelExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // label is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getLabel() != null) { proto.setLabel( ResolvedNodes.serialize(this.getLabel(), fileDescriptorSetsBuilder)); } } /** * Points to a label in the catalog */ public final GraphElementLabel getLabel() { return label; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphLabel accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("label", DebugStrings.toStringImpl(label))); } } } /** * This represents the wildcard label % that matches any label in the graph. */ public static final class ResolvedGraphWildCardLabel extends ResolvedGraphLabelExpr { ResolvedGraphWildCardLabel(ResolvedGraphWildCardLabelProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedGraphWildCardLabel() { super(); } @Override public Builder toBuilder() { Builder builder = builder(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGraphLabelExpr.Builder { private Builder() {} @Override public final ResolvedGraphWildCardLabel build() { validate(); return new ResolvedGraphWildCardLabel(); } @Override protected void validate() { super.validate(); } } public static final ResolvedGraphWildCardLabel deserialize( ResolvedGraphWildCardLabelProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphWildCardLabel(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_WILD_CARD_LABEL; } @Override public final String nodeKindString() { return "GraphWildCardLabel"; } /** * Serializes this node into a {@link AnyResolvedGraphLabelExprProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGraphLabelExprProto.Builder builder = AnyResolvedGraphLabelExprProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGraphLabelExprProto.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, AnyResolvedGraphLabelExprProto.Builder builder) { builder.clear(); ResolvedGraphWildCardLabelProto.Builder childBuilder = ResolvedGraphWildCardLabelProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphWildCardLabelNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphWildCardLabelProto.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, ResolvedGraphWildCardLabelProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGraphLabelExprProto parent = (ResolvedGraphLabelExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphWildCardLabel accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * Represents the identifier of a graph element within a graph. * See (broken link):graph-element-identifiers for more details. * *

: the ElementTable that produced this graph element; * : references to the key columns of the ; * : identifiers of source/destination node * of an edge: must be set if the element is an edge; must be null if * the element is a node. */ public static final class ResolvedGraphElementIdentifier extends ResolvedArgument { private final GraphElementTable elementTable; private final ImmutableList keyList; private final ResolvedGraphElementIdentifier sourceNodeIdentifier; private final ResolvedGraphElementIdentifier destNodeIdentifier; ResolvedGraphElementIdentifier(ResolvedGraphElementIdentifierProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); elementTable = helper.deserialize(proto.getElementTable()); ImmutableList.Builder keyListBuilder = ImmutableList.builder(); for (AnyResolvedExprProto element : proto.getKeyListList()) { keyListBuilder .add(ResolvedExpr.deserialize(element, helper)); } keyList = keyListBuilder.build(); if (proto.hasSourceNodeIdentifier()) { sourceNodeIdentifier = ResolvedGraphElementIdentifier.deserialize(proto.getSourceNodeIdentifier(), helper); } else { sourceNodeIdentifier = null; } if (proto.hasDestNodeIdentifier()) { destNodeIdentifier = ResolvedGraphElementIdentifier.deserialize(proto.getDestNodeIdentifier(), helper); } else { destNodeIdentifier = null; } } ResolvedGraphElementIdentifier( GraphElementTable elementTable, ImmutableList keyList, ResolvedGraphElementIdentifier sourceNodeIdentifier, ResolvedGraphElementIdentifier destNodeIdentifier) { super(); this.elementTable = elementTable; this.keyList = keyList; this.sourceNodeIdentifier = sourceNodeIdentifier; this.destNodeIdentifier = destNodeIdentifier; } @Override public Builder toBuilder() { Builder builder = builder(); builder.elementTable = this.getElementTable(); builder.keyList = this.getKeyList(); builder.sourceNodeIdentifier = this.getSourceNodeIdentifier(); builder.destNodeIdentifier = this.getDestNodeIdentifier(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected GraphElementTable elementTable = null; protected ImmutableList keyList = null; protected ResolvedGraphElementIdentifier sourceNodeIdentifier = null; protected ResolvedGraphElementIdentifier destNodeIdentifier = null; private Builder() {} @CanIgnoreReturnValue public Builder setElementTable(GraphElementTable v) { this.elementTable = v; Preconditions.checkNotNull(v, "elementTable must not be null"); return this; } @CanIgnoreReturnValue public Builder setKeyList(List v) { this.keyList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setSourceNodeIdentifier(ResolvedGraphElementIdentifier v) { this.sourceNodeIdentifier = v; return this; } @CanIgnoreReturnValue public Builder setDestNodeIdentifier(ResolvedGraphElementIdentifier v) { this.destNodeIdentifier = v; return this; } @Override public final ResolvedGraphElementIdentifier build() { validate(); return new ResolvedGraphElementIdentifier( elementTable, keyList, sourceNodeIdentifier, destNodeIdentifier); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( elementTable != null, "elementTable must be set"); Preconditions.checkArgument( keyList != null, "keyList must be set"); } } public static final ResolvedGraphElementIdentifier deserialize( ResolvedGraphElementIdentifierProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphElementIdentifier(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_ELEMENT_IDENTIFIER; } @Override public final String nodeKindString() { return "GraphElementIdentifier"; } /** * 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(); ResolvedGraphElementIdentifierProto.Builder childBuilder = ResolvedGraphElementIdentifierProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphElementIdentifierNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphElementIdentifierProto.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, ResolvedGraphElementIdentifierProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // elementTable is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getElementTable() != null) { proto.setElementTable( ResolvedNodes.serialize(this.getElementTable(), fileDescriptorSetsBuilder)); } // keyList is a collection of AST nodes. Serialize each of them. ImmutableList keyLists = this.getKeyList(); for (ResolvedExpr element : keyLists) { AnyResolvedExprProto.Builder keyListBuilder = AnyResolvedExprProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, keyListBuilder); proto.addKeyList(keyListBuilder.build()); } // sourceNodeIdentifier is an AST node. Call its serialization chain. if (this.getSourceNodeIdentifier() != null) { ResolvedGraphElementIdentifierProto.Builder sourceNodeIdentifierBuilder = ResolvedGraphElementIdentifierProto.newBuilder(); this.getSourceNodeIdentifier().serialize( fileDescriptorSetsBuilder, sourceNodeIdentifierBuilder); proto.setSourceNodeIdentifier( sourceNodeIdentifierBuilder.build()); } // destNodeIdentifier is an AST node. Call its serialization chain. if (this.getDestNodeIdentifier() != null) { ResolvedGraphElementIdentifierProto.Builder destNodeIdentifierBuilder = ResolvedGraphElementIdentifierProto.newBuilder(); this.getDestNodeIdentifier().serialize( fileDescriptorSetsBuilder, destNodeIdentifierBuilder); proto.setDestNodeIdentifier( destNodeIdentifierBuilder.build()); } } public final GraphElementTable getElementTable() { return elementTable; } public final ImmutableList getKeyList() { return keyList; } public final ResolvedGraphElementIdentifier getSourceNodeIdentifier() { return sourceNodeIdentifier; } public final ResolvedGraphElementIdentifier getDestNodeIdentifier() { return destNodeIdentifier; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphElementIdentifier accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(keyList); visitor.descend(sourceNodeIdentifier); visitor.descend(destNodeIdentifier); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("element_table", DebugStrings.toStringImpl(elementTable))); } if (!keyList.isEmpty()) { fields.add(new DebugStringField("key_list", keyList)); } if (sourceNodeIdentifier != null) { fields.add(new DebugStringField("source_node_identifier", sourceNodeIdentifier)); } if (destNodeIdentifier != null) { fields.add(new DebugStringField("dest_node_identifier", destNodeIdentifier)); } } } /** * Represents a graph element property of a graph element. * *

refers to the property declaration catalog object; * is the value expression for the . */ public static final class ResolvedGraphElementProperty extends ResolvedArgument { private final GraphPropertyDeclaration declaration; private final ResolvedExpr expr; ResolvedGraphElementProperty(ResolvedGraphElementPropertyProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); declaration = helper.deserialize(proto.getDeclaration()); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } } ResolvedGraphElementProperty( GraphPropertyDeclaration declaration, ResolvedExpr expr) { super(); this.declaration = declaration; this.expr = expr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.declaration = this.getDeclaration(); builder.expr = this.getExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected GraphPropertyDeclaration declaration = null; protected ResolvedExpr expr = null; private Builder() {} @CanIgnoreReturnValue public Builder setDeclaration(GraphPropertyDeclaration v) { this.declaration = v; Preconditions.checkNotNull(v, "declaration must not be null"); return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @Override public final ResolvedGraphElementProperty build() { validate(); return new ResolvedGraphElementProperty( declaration, expr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( declaration != null, "declaration must be set"); Preconditions.checkArgument( expr != null, "expr must be set"); } } public static final ResolvedGraphElementProperty deserialize( ResolvedGraphElementPropertyProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphElementProperty(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_ELEMENT_PROPERTY; } @Override public final String nodeKindString() { return "GraphElementProperty"; } /** * 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(); ResolvedGraphElementPropertyProto.Builder childBuilder = ResolvedGraphElementPropertyProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphElementPropertyNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphElementPropertyProto.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, ResolvedGraphElementPropertyProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // declaration is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getDeclaration() != null) { proto.setDeclaration( ResolvedNodes.serialize(this.getDeclaration(), 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 GraphPropertyDeclaration getDeclaration() { return declaration; } public final ResolvedExpr getExpr() { return expr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphElementProperty accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("declaration", DebugStrings.toStringImpl(declaration))); } if (expr != null) { fields.add(new DebugStringField("expr", expr)); } } } /** * Constructs a graph element. is always a GraphElementType. * *

uniquely identifies a graph element in the graph; * contains a list of properties and their definitions; * contains a list of label catalog objects that are exposed * by the graph element. */ public static final class ResolvedGraphMakeElement extends ResolvedExpr { private final ResolvedGraphElementIdentifier identifier; private final ImmutableList propertyList; private final ImmutableList labelList; ResolvedGraphMakeElement(ResolvedGraphMakeElementProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasIdentifier()) { identifier = ResolvedGraphElementIdentifier.deserialize(proto.getIdentifier(), helper); } else { identifier = null; } ImmutableList.Builder propertyListBuilder = ImmutableList.builder(); for (ResolvedGraphElementPropertyProto element : proto.getPropertyListList()) { propertyListBuilder .add(ResolvedGraphElementProperty.deserialize(element, helper)); } propertyList = propertyListBuilder.build(); ImmutableList.Builder labelListBuilder = ImmutableList.builder(); for (GraphElementLabelRefProto element : proto.getLabelListList()) { labelListBuilder.add(helper.deserialize(element)); } labelList = labelListBuilder.build(); } ResolvedGraphMakeElement( Type type, AnnotationMap typeAnnotationMap, ResolvedGraphElementIdentifier identifier, ImmutableList propertyList, ImmutableList labelList) { super( type, typeAnnotationMap); this.identifier = identifier; this.propertyList = propertyList; this.labelList = labelList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.identifier = this.getIdentifier(); builder.propertyList = this.getPropertyList(); builder.labelList = this.getLabelList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedGraphElementIdentifier identifier = null; protected ImmutableList propertyList = null; protected ImmutableList labelList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setIdentifier(ResolvedGraphElementIdentifier v) { this.identifier = v; Preconditions.checkNotNull(v, "identifier must not be null"); return this; } @CanIgnoreReturnValue public Builder setPropertyList(List v) { this.propertyList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setLabelList(List v) { this.labelList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedGraphMakeElement build() { validate(); return new ResolvedGraphMakeElement( type, typeAnnotationMap, identifier, propertyList, labelList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( identifier != null, "identifier must be set"); Preconditions.checkArgument( propertyList != null, "propertyList must be set"); Preconditions.checkArgument( labelList != null, "labelList must be set"); } } public static final ResolvedGraphMakeElement deserialize( ResolvedGraphMakeElementProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphMakeElement(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_MAKE_ELEMENT; } @Override public final String nodeKindString() { return "GraphMakeElement"; } /** * 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(); ResolvedGraphMakeElementProto.Builder childBuilder = ResolvedGraphMakeElementProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphMakeElementNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphMakeElementProto.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, ResolvedGraphMakeElementProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // identifier is an AST node. Call its serialization chain. if (this.getIdentifier() != null) { ResolvedGraphElementIdentifierProto.Builder identifierBuilder = ResolvedGraphElementIdentifierProto.newBuilder(); this.getIdentifier().serialize( fileDescriptorSetsBuilder, identifierBuilder); proto.setIdentifier( identifierBuilder.build()); } // propertyList is a collection of AST nodes. Serialize each of them. ImmutableList propertyLists = this.getPropertyList(); for (ResolvedGraphElementProperty element : propertyLists) { ResolvedGraphElementPropertyProto.Builder propertyListBuilder = ResolvedGraphElementPropertyProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, propertyListBuilder); proto.addPropertyList(propertyListBuilder.build()); } // labelList is a collection of leaf types that require a helper method to serialize. // (see scalar types in (broken link).py for more information.) ImmutableList labelLists = this.getLabelList(); for (GraphElementLabel element : labelLists) { proto.addLabelList(ResolvedNodes.serialize(element, fileDescriptorSetsBuilder)); } } public final ResolvedGraphElementIdentifier getIdentifier() { return identifier; } public final ImmutableList getPropertyList() { return propertyList; } public final ImmutableList getLabelList() { return labelList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphMakeElement accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(identifier); visitor.descend(propertyList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (identifier != null) { fields.add(new DebugStringField("identifier", identifier)); } if (!propertyList.isEmpty()) { fields.add(new DebugStringField("property_list", propertyList)); } { fields.add(new DebugStringField("label_list", DebugStrings.toStringCommaSeparatedForGraphElementLabel(labelList))); } } } /** * Computes an aggregate over the elements of an array. * *

For each element in , produce an input row for the aggregate * as follows: * - Let be the array element. * - Compute the expressions in , * which may refer to and . * Then evaluate over these rows. It may reference these * new columns, or any other columns in scope for this node. * *

The aggregate input rows use the original 's order unless * has an ORDER BY modifier. * *

and the columns in * are not visible outside this node. * *

can be any ResolvedExpr. Today it's always a ResolvedColumnRef * because the only user is graph's horizontal aggregation and that is * baked into the SQLBuilder implementation. */ public static final class ResolvedArrayAggregate extends ResolvedExpr { private final ResolvedExpr array; private final ResolvedColumn elementColumn; private final ImmutableList preAggregateComputedColumnList; private final ResolvedAggregateFunctionCall aggregate; ResolvedArrayAggregate(ResolvedArrayAggregateProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasArray()) { array = ResolvedExpr.deserialize(proto.getArray(), helper); } else { array = null; } elementColumn = helper.deserialize(proto.getElementColumn()); ImmutableList.Builder preAggregateComputedColumnListBuilder = ImmutableList.builder(); for (ResolvedComputedColumnProto element : proto.getPreAggregateComputedColumnListList()) { preAggregateComputedColumnListBuilder .add(ResolvedComputedColumn.deserialize(element, helper)); } preAggregateComputedColumnList = preAggregateComputedColumnListBuilder.build(); if (proto.hasAggregate()) { aggregate = ResolvedAggregateFunctionCall.deserialize(proto.getAggregate(), helper); } else { aggregate = null; } } ResolvedArrayAggregate( Type type, AnnotationMap typeAnnotationMap, ResolvedExpr array, ResolvedColumn elementColumn, ImmutableList preAggregateComputedColumnList, ResolvedAggregateFunctionCall aggregate) { super( type, typeAnnotationMap); this.array = array; this.elementColumn = elementColumn; this.preAggregateComputedColumnList = preAggregateComputedColumnList; this.aggregate = aggregate; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.array = this.getArray(); builder.elementColumn = this.getElementColumn(); builder.preAggregateComputedColumnList = this.getPreAggregateComputedColumnList(); builder.aggregate = this.getAggregate(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected ResolvedExpr array = null; protected ResolvedColumn elementColumn = null; protected ImmutableList preAggregateComputedColumnList = null; protected ResolvedAggregateFunctionCall aggregate = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setArray(ResolvedExpr v) { this.array = v; Preconditions.checkNotNull(v, "array must not be null"); return this; } @CanIgnoreReturnValue public Builder setElementColumn(ResolvedColumn v) { this.elementColumn = v; Preconditions.checkNotNull(v, "elementColumn must not be null"); return this; } @CanIgnoreReturnValue public Builder setPreAggregateComputedColumnList(List v) { this.preAggregateComputedColumnList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setAggregate(ResolvedAggregateFunctionCall v) { this.aggregate = v; Preconditions.checkNotNull(v, "aggregate must not be null"); return this; } @Override public final ResolvedArrayAggregate build() { validate(); return new ResolvedArrayAggregate( type, typeAnnotationMap, array, elementColumn, preAggregateComputedColumnList, aggregate); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( array != null, "array must be set"); Preconditions.checkArgument( elementColumn != null, "elementColumn must be set"); Preconditions.checkArgument( preAggregateComputedColumnList != null, "preAggregateComputedColumnList must be set"); Preconditions.checkArgument( aggregate != null, "aggregate must be set"); } } public static final ResolvedArrayAggregate deserialize( ResolvedArrayAggregateProto proto, AbstractDeserializationHelper helper) { return new ResolvedArrayAggregate(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ARRAY_AGGREGATE; } @Override public final String nodeKindString() { return "ArrayAggregate"; } /** * 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(); ResolvedArrayAggregateProto.Builder childBuilder = ResolvedArrayAggregateProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedArrayAggregateNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedArrayAggregateProto.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, ResolvedArrayAggregateProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // array is an AST node. Call its serialization chain. if (this.getArray() != null) { AnyResolvedExprProto.Builder arrayBuilder = AnyResolvedExprProto.newBuilder(); this.getArray().serialize( fileDescriptorSetsBuilder, arrayBuilder); proto.setArray( arrayBuilder.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)); } // preAggregateComputedColumnList is a collection of AST nodes. Serialize each of them. ImmutableList preAggregateComputedColumnLists = this.getPreAggregateComputedColumnList(); for (ResolvedComputedColumn element : preAggregateComputedColumnLists) { ResolvedComputedColumnProto.Builder preAggregateComputedColumnListBuilder = ResolvedComputedColumnProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, preAggregateComputedColumnListBuilder); proto.addPreAggregateComputedColumnList(preAggregateComputedColumnListBuilder.build()); } // aggregate is an AST node. Call its serialization chain. if (this.getAggregate() != null) { ResolvedAggregateFunctionCallProto.Builder aggregateBuilder = ResolvedAggregateFunctionCallProto.newBuilder(); this.getAggregate().serialize( fileDescriptorSetsBuilder, aggregateBuilder); proto.setAggregate( aggregateBuilder.build()); } } public final ResolvedExpr getArray() { return array; } public final ResolvedColumn getElementColumn() { return elementColumn; } public final ImmutableList getPreAggregateComputedColumnList() { return preAggregateComputedColumnList; } public final ResolvedAggregateFunctionCall getAggregate() { return aggregate; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedArrayAggregate accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(array); visitor.descend(preAggregateComputedColumnList); visitor.descend(aggregate); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (array != null) { fields.add(new DebugStringField("array", array)); } { fields.add(new DebugStringField("element_column", DebugStrings.toStringImpl(elementColumn))); } if (!preAggregateComputedColumnList.isEmpty()) { fields.add(new DebugStringField("pre_aggregate_computed_column_list", preAggregateComputedColumnList)); } if (aggregate != null) { fields.add(new DebugStringField("aggregate", aggregate)); } } } /** * ResolvedGraphMakeArrayVariable populates the newly created * column with the values that takes across iterations of the * quantified path. For example, the resolved path `((a) - (b)){3}` will * contain two ResolvedGraphMakeArrayVariables, one creating the * array-typed column with the three values that `a` takes along the * quantified path; same for `b`. * *

The type of must be an array with element type . */ public static final class ResolvedGraphMakeArrayVariable extends ResolvedArgument { private final ResolvedColumn element; private final ResolvedColumn array; ResolvedGraphMakeArrayVariable(ResolvedGraphMakeArrayVariableProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); element = helper.deserialize(proto.getElement()); array = helper.deserialize(proto.getArray()); } ResolvedGraphMakeArrayVariable( ResolvedColumn element, ResolvedColumn array) { super(); this.element = element; this.array = array; } @Override public Builder toBuilder() { Builder builder = builder(); builder.element = this.getElement(); builder.array = this.getArray(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedColumn element = null; protected ResolvedColumn array = null; private Builder() {} @CanIgnoreReturnValue public Builder setElement(ResolvedColumn v) { this.element = v; Preconditions.checkNotNull(v, "element must not be null"); return this; } @CanIgnoreReturnValue public Builder setArray(ResolvedColumn v) { this.array = v; Preconditions.checkNotNull(v, "array must not be null"); return this; } @Override public final ResolvedGraphMakeArrayVariable build() { validate(); return new ResolvedGraphMakeArrayVariable( element, array); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( element != null, "element must be set"); Preconditions.checkArgument( array != null, "array must be set"); } } public static final ResolvedGraphMakeArrayVariable deserialize( ResolvedGraphMakeArrayVariableProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphMakeArrayVariable(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_MAKE_ARRAY_VARIABLE; } @Override public final String nodeKindString() { return "GraphMakeArrayVariable"; } /** * 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(); ResolvedGraphMakeArrayVariableProto.Builder childBuilder = ResolvedGraphMakeArrayVariableProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphMakeArrayVariableNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphMakeArrayVariableProto.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, ResolvedGraphMakeArrayVariableProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // element is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getElement() != null) { proto.setElement( ResolvedNodes.serialize(this.getElement(), fileDescriptorSetsBuilder)); } // array is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getArray() != null) { proto.setArray( ResolvedNodes.serialize(this.getArray(), fileDescriptorSetsBuilder)); } } public final ResolvedColumn getElement() { return element; } public final ResolvedColumn getArray() { return array; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphMakeArrayVariable accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("element", DebugStrings.toStringImpl(element))); } { fields.add(new DebugStringField("array", DebugStrings.toStringImpl(array))); } } } /** * Path mode specifies ways to restrict the nodes and edges on a particular * path. It currently provides the ability to prevent duplicate edges with * TRAIL, duplicate nodes with ACYCLIC, and duplicate nodes except possibly * the head and the tail of the path with SIMPLE. */ public static final class ResolvedGraphPathMode extends ResolvedArgument { private final PathMode pathMode; ResolvedGraphPathMode(ResolvedGraphPathModeProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); pathMode = proto.getPathMode(); } ResolvedGraphPathMode( PathMode pathMode) { super(); this.pathMode = pathMode; } @Override public Builder toBuilder() { Builder builder = builder(); builder.pathMode = this.getPathMode(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected PathMode pathMode = null; private Builder() {} @CanIgnoreReturnValue public Builder setPathMode(PathMode v) { this.pathMode = v; Preconditions.checkNotNull(v, "pathMode must not be null"); return this; } @Override public final ResolvedGraphPathMode build() { validate(); return new ResolvedGraphPathMode( pathMode); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( pathMode != null, "pathMode must be set"); } } public static final ResolvedGraphPathMode deserialize( ResolvedGraphPathModeProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphPathMode(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_PATH_MODE; } @Override public final String nodeKindString() { return "GraphPathMode"; } /** * 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(); ResolvedGraphPathModeProto.Builder childBuilder = ResolvedGraphPathModeProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphPathModeNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphPathModeProto.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, ResolvedGraphPathModeProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // pathMode is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setPathMode(this.getPathMode()); } public final PathMode getPathMode() { return pathMode; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphPathMode accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("path_mode", DebugStrings.toStringImpl(pathMode))); } } } /** * ResolvedGraphPathScan represents a scan of matching sequences of * sub-paths or graph elements (i.e. paths) from the graph. * *

ResolvedGraphPathScan matches paths that: for the sequence of elements * along the path: * 1) node/edge output from successive node pattern and edge pattern * satisfy edge pattern's orientation constraint: * the matching node must be the source or the destination of the * matching edge; * 2) evaluates true for the matching graph elements. * 3) denotes a hint on a traversal between the * previous path to this path, so the first path in a graph pattern * will not contain a 'path hint'. Note that this is different from * the parent ResolvedScan node's 'hint_list' which belongs to the * scan itself. * * *

and are the first and last graph node of the path * respectively. * *

Consecutive paths match when the of the first path is the same * as the of the second path. * *

A path is either quantified or not. If quantified: * 1) and must be present. * 2) is a list of (, ) columns. * For each column, this scan will populate the * corresponding column with an array of all the values * that column took across the iterations of the * quantified path in iteration order. Every column comes * from . contains the , * , and all of the columns from * * *

If the path is not quantified: * 1) and must not be present. * 2) The will contain columns from the s of * the input scans, which represents elements in the path. * *

If is present, it must be a path-typed column that can be * constructed from the paths and graph elements in . * This scan will populate with the nodes and edges that are * matched along the path. If is set on a ResolvedGraphPathScan it * must be set on all descendant ResolvedGraphPathScans. must be a * new column. */ public static final class ResolvedGraphPathScan extends ResolvedGraphPathScanBase { private final ImmutableList inputScanList; private final ResolvedExpr filterExpr; private final ResolvedColumnHolder path; private final ResolvedColumn head; private final ResolvedColumn tail; private final ImmutableList pathHintList; /** * */ private final ResolvedGraphPathPatternQuantifier quantifier; private final ImmutableList groupVariableList; private final ResolvedGraphPathMode pathMode; private final ResolvedGraphPathSearchPrefix searchPrefix; ResolvedGraphPathScan(ResolvedGraphPathScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder inputScanListBuilder = ImmutableList.builder(); for (AnyResolvedGraphPathScanBaseProto element : proto.getInputScanListList()) { inputScanListBuilder .add(ResolvedGraphPathScanBase.deserialize(element, helper)); } inputScanList = inputScanListBuilder.build(); if (proto.hasFilterExpr()) { filterExpr = ResolvedExpr.deserialize(proto.getFilterExpr(), helper); } else { filterExpr = null; } if (proto.hasPath()) { path = ResolvedColumnHolder.deserialize(proto.getPath(), helper); } else { path = null; } head = helper.deserialize(proto.getHead()); tail = helper.deserialize(proto.getTail()); ImmutableList.Builder pathHintListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getPathHintListList()) { pathHintListBuilder .add(ResolvedOption.deserialize(element, helper)); } pathHintList = pathHintListBuilder.build(); if (proto.hasQuantifier()) { quantifier = ResolvedGraphPathPatternQuantifier.deserialize(proto.getQuantifier(), helper); } else { quantifier = null; } ImmutableList.Builder groupVariableListBuilder = ImmutableList.builder(); for (ResolvedGraphMakeArrayVariableProto element : proto.getGroupVariableListList()) { groupVariableListBuilder .add(ResolvedGraphMakeArrayVariable.deserialize(element, helper)); } groupVariableList = groupVariableListBuilder.build(); if (proto.hasPathMode()) { pathMode = ResolvedGraphPathMode.deserialize(proto.getPathMode(), helper); } else { pathMode = null; } if (proto.hasSearchPrefix()) { searchPrefix = ResolvedGraphPathSearchPrefix.deserialize(proto.getSearchPrefix(), helper); } else { searchPrefix = null; } } ResolvedGraphPathScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ImmutableList inputScanList, ResolvedExpr filterExpr, ResolvedColumnHolder path, ResolvedColumn head, ResolvedColumn tail, ImmutableList pathHintList, ResolvedGraphPathPatternQuantifier quantifier, ImmutableList groupVariableList, ResolvedGraphPathMode pathMode, ResolvedGraphPathSearchPrefix searchPrefix) { super( columnList, hintList, isOrdered, nodeSource); this.inputScanList = inputScanList; this.filterExpr = filterExpr; this.path = path; this.head = head; this.tail = tail; this.pathHintList = pathHintList; this.quantifier = quantifier; this.groupVariableList = groupVariableList; this.pathMode = pathMode; this.searchPrefix = searchPrefix; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScanList = this.getInputScanList(); builder.filterExpr = this.getFilterExpr(); builder.path = this.getPath(); builder.head = this.getHead(); builder.tail = this.getTail(); builder.pathHintList = this.getPathHintList(); builder.quantifier = this.getQuantifier(); builder.groupVariableList = this.getGroupVariableList(); builder.pathMode = this.getPathMode(); builder.searchPrefix = this.getSearchPrefix(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedGraphPathScanBase.Builder { protected ImmutableList inputScanList = null; protected ResolvedExpr filterExpr = null; protected ResolvedColumnHolder path = null; protected ResolvedColumn head = null; protected ResolvedColumn tail = null; protected ImmutableList pathHintList = ImmutableList.of(); protected ResolvedGraphPathPatternQuantifier quantifier = null; protected ImmutableList groupVariableList = null; protected ResolvedGraphPathMode pathMode = null; protected ResolvedGraphPathSearchPrefix searchPrefix = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScanList(List v) { this.inputScanList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setFilterExpr(ResolvedExpr v) { this.filterExpr = v; Preconditions.checkNotNull(v, "filterExpr must not be null"); return this; } @CanIgnoreReturnValue public Builder setPath(ResolvedColumnHolder v) { this.path = v; return this; } @CanIgnoreReturnValue public Builder setHead(ResolvedColumn v) { this.head = v; Preconditions.checkNotNull(v, "head must not be null"); return this; } @CanIgnoreReturnValue public Builder setTail(ResolvedColumn v) { this.tail = v; Preconditions.checkNotNull(v, "tail must not be null"); return this; } @CanIgnoreReturnValue public Builder setPathHintList(List v) { this.pathHintList = ImmutableList.copyOf(v); return this; } /** * */ @CanIgnoreReturnValue public Builder setQuantifier(ResolvedGraphPathPatternQuantifier v) { this.quantifier = v; return this; } @CanIgnoreReturnValue public Builder setGroupVariableList(List v) { this.groupVariableList = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setPathMode(ResolvedGraphPathMode v) { this.pathMode = v; Preconditions.checkNotNull(v, "pathMode must not be null"); return this; } @CanIgnoreReturnValue public Builder setSearchPrefix(ResolvedGraphPathSearchPrefix v) { this.searchPrefix = v; return this; } @Override public final ResolvedGraphPathScan build() { validate(); return new ResolvedGraphPathScan( columnList, hintList, isOrdered, nodeSource, inputScanList, filterExpr, path, head, tail, pathHintList, quantifier, groupVariableList, pathMode, searchPrefix); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScanList != null, "inputScanList must be set"); Preconditions.checkArgument( filterExpr != null, "filterExpr must be set"); Preconditions.checkArgument( head != null, "head must be set"); Preconditions.checkArgument( tail != null, "tail must be set"); Preconditions.checkArgument( pathMode != null, "pathMode must be set"); } } public static final ResolvedGraphPathScan deserialize( ResolvedGraphPathScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphPathScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_PATH_SCAN; } @Override public final String nodeKindString() { return "GraphPathScan"; } /** * Serializes this node into a {@link AnyResolvedGraphPathScanBaseProto}. * Adds any new file descriptor sets it encounters to the builder. */ @Override public final Message serialize(FileDescriptorSetsBuilder fileDescriptorSetsBuilder) { AnyResolvedGraphPathScanBaseProto.Builder builder = AnyResolvedGraphPathScanBaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, builder); return builder.build(); } /** * Serializes this node into the appropriate field of the provided * {@link AnyResolvedGraphPathScanBaseProto.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, AnyResolvedGraphPathScanBaseProto.Builder builder) { builder.clear(); ResolvedGraphPathScanProto.Builder childBuilder = ResolvedGraphPathScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphPathScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphPathScanProto.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, ResolvedGraphPathScanProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedGraphPathScanBaseProto parent = (ResolvedGraphPathScanBaseProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // inputScanList is a collection of AST nodes. Serialize each of them. ImmutableList inputScanLists = this.getInputScanList(); for (ResolvedGraphPathScanBase element : inputScanLists) { AnyResolvedGraphPathScanBaseProto.Builder inputScanListBuilder = AnyResolvedGraphPathScanBaseProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, inputScanListBuilder); proto.addInputScanList(inputScanListBuilder.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()); } // path is an AST node. Call its serialization chain. if (this.getPath() != null) { ResolvedColumnHolderProto.Builder pathBuilder = ResolvedColumnHolderProto.newBuilder(); this.getPath().serialize( fileDescriptorSetsBuilder, pathBuilder); proto.setPath( pathBuilder.build()); } // head is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getHead() != null) { proto.setHead( ResolvedNodes.serialize(this.getHead(), fileDescriptorSetsBuilder)); } // tail is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getTail() != null) { proto.setTail( ResolvedNodes.serialize(this.getTail(), fileDescriptorSetsBuilder)); } // pathHintList is a collection of AST nodes. Serialize each of them. ImmutableList pathHintLists = this.getPathHintList(); for (ResolvedOption element : pathHintLists) { ResolvedOptionProto.Builder pathHintListBuilder = ResolvedOptionProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, pathHintListBuilder); proto.addPathHintList(pathHintListBuilder.build()); } // quantifier is an AST node. Call its serialization chain. if (this.getQuantifier() != null) { ResolvedGraphPathPatternQuantifierProto.Builder quantifierBuilder = ResolvedGraphPathPatternQuantifierProto.newBuilder(); this.getQuantifier().serialize( fileDescriptorSetsBuilder, quantifierBuilder); proto.setQuantifier( quantifierBuilder.build()); } // groupVariableList is a collection of AST nodes. Serialize each of them. ImmutableList groupVariableLists = this.getGroupVariableList(); for (ResolvedGraphMakeArrayVariable element : groupVariableLists) { ResolvedGraphMakeArrayVariableProto.Builder groupVariableListBuilder = ResolvedGraphMakeArrayVariableProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, groupVariableListBuilder); proto.addGroupVariableList(groupVariableListBuilder.build()); } // pathMode is an AST node. Call its serialization chain. if (this.getPathMode() != null) { ResolvedGraphPathModeProto.Builder pathModeBuilder = ResolvedGraphPathModeProto.newBuilder(); this.getPathMode().serialize( fileDescriptorSetsBuilder, pathModeBuilder); proto.setPathMode( pathModeBuilder.build()); } // searchPrefix is an AST node. Call its serialization chain. if (this.getSearchPrefix() != null) { ResolvedGraphPathSearchPrefixProto.Builder searchPrefixBuilder = ResolvedGraphPathSearchPrefixProto.newBuilder(); this.getSearchPrefix().serialize( fileDescriptorSetsBuilder, searchPrefixBuilder); proto.setSearchPrefix( searchPrefixBuilder.build()); } } public final ImmutableList getInputScanList() { return inputScanList; } public final ResolvedExpr getFilterExpr() { return filterExpr; } public final ResolvedColumnHolder getPath() { return path; } public final ResolvedColumn getHead() { return head; } public final ResolvedColumn getTail() { return tail; } public final ImmutableList getPathHintList() { return pathHintList; } /** * */ public final ResolvedGraphPathPatternQuantifier getQuantifier() { return quantifier; } public final ImmutableList getGroupVariableList() { return groupVariableList; } public final ResolvedGraphPathMode getPathMode() { return pathMode; } public final ResolvedGraphPathSearchPrefix getSearchPrefix() { return searchPrefix; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphPathScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScanList); visitor.descend(filterExpr); visitor.descend(path); visitor.descend(pathHintList); visitor.descend(quantifier); visitor.descend(groupVariableList); visitor.descend(pathMode); visitor.descend(searchPrefix); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!inputScanList.isEmpty()) { fields.add(new DebugStringField("input_scan_list", inputScanList)); } if (filterExpr != null) { fields.add(new DebugStringField("filter_expr", filterExpr)); } if (path != null) { fields.add(new DebugStringField("path", path)); } { fields.add(new DebugStringField("head", DebugStrings.toStringImpl(head))); } { fields.add(new DebugStringField("tail", DebugStrings.toStringImpl(tail))); } if (!pathHintList.isEmpty()) { fields.add(new DebugStringField("path_hint_list", pathHintList)); } if (quantifier != null) { fields.add(new DebugStringField("quantifier", quantifier)); } if (!groupVariableList.isEmpty()) { fields.add(new DebugStringField("group_variable_list", groupVariableList)); } if (pathMode != null) { fields.add(new DebugStringField("path_mode", pathMode)); } if (searchPrefix != null) { fields.add(new DebugStringField("search_prefix", searchPrefix)); } } } /** * Represents IS LABELED predicate for graph elements, a boolean expression * that evaluates to true if the graph element satisfies the given * label expression. * represents the LHS which should always be a column reference of * GraphElementType. * represents the RHS which should always be a * ResolvedGraphLabelExpr. * is true if the predicate is negated. */ public static final class ResolvedGraphIsLabeledPredicate extends ResolvedExpr { private final boolean isNot; private final ResolvedExpr expr; private final ResolvedGraphLabelExpr labelExpr; ResolvedGraphIsLabeledPredicate(ResolvedGraphIsLabeledPredicateProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); isNot = proto.getIsNot(); if (proto.hasExpr()) { expr = ResolvedExpr.deserialize(proto.getExpr(), helper); } else { expr = null; } if (proto.hasLabelExpr()) { labelExpr = ResolvedGraphLabelExpr.deserialize(proto.getLabelExpr(), helper); } else { labelExpr = null; } } ResolvedGraphIsLabeledPredicate( Type type, AnnotationMap typeAnnotationMap, boolean isNot, ResolvedExpr expr, ResolvedGraphLabelExpr labelExpr) { super( type, typeAnnotationMap); this.isNot = isNot; this.expr = expr; this.labelExpr = labelExpr; } @Override public Builder toBuilder() { Builder builder = builder(); builder.type = this.getType(); builder.typeAnnotationMap = this.getTypeAnnotationMap(); builder.isNot = this.getIsNot(); builder.expr = this.getExpr(); builder.labelExpr = this.getLabelExpr(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedExpr.Builder { protected Boolean isNot = null; protected ResolvedExpr expr = null; protected ResolvedGraphLabelExpr labelExpr = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setType(Type v) { super.setType(v); return this; } @Override @CanIgnoreReturnValue public Builder setTypeAnnotationMap(AnnotationMap v) { super.setTypeAnnotationMap(v); return this; } @CanIgnoreReturnValue public Builder setIsNot(boolean v) { this.isNot = v; return this; } @CanIgnoreReturnValue public Builder setExpr(ResolvedExpr v) { this.expr = v; Preconditions.checkNotNull(v, "expr must not be null"); return this; } @CanIgnoreReturnValue public Builder setLabelExpr(ResolvedGraphLabelExpr v) { this.labelExpr = v; Preconditions.checkNotNull(v, "labelExpr must not be null"); return this; } @Override public final ResolvedGraphIsLabeledPredicate build() { validate(); return new ResolvedGraphIsLabeledPredicate( type, typeAnnotationMap, isNot, expr, labelExpr); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( expr != null, "expr must be set"); Preconditions.checkArgument( labelExpr != null, "labelExpr must be set"); } } public static final ResolvedGraphIsLabeledPredicate deserialize( ResolvedGraphIsLabeledPredicateProto proto, AbstractDeserializationHelper helper) { return new ResolvedGraphIsLabeledPredicate(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GRAPH_IS_LABELED_PREDICATE; } @Override public final String nodeKindString() { return "GraphIsLabeledPredicate"; } /** * 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(); ResolvedGraphIsLabeledPredicateProto.Builder childBuilder = ResolvedGraphIsLabeledPredicateProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGraphIsLabeledPredicateNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGraphIsLabeledPredicateProto.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, ResolvedGraphIsLabeledPredicateProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedExprProto parent = (ResolvedExprProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // isNot is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setIsNot(this.getIsNot()); // 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()); } // labelExpr is an AST node. Call its serialization chain. if (this.getLabelExpr() != null) { AnyResolvedGraphLabelExprProto.Builder labelExprBuilder = AnyResolvedGraphLabelExprProto.newBuilder(); this.getLabelExpr().serialize( fileDescriptorSetsBuilder, labelExprBuilder); proto.setLabelExpr( labelExprBuilder.build()); } } public final boolean getIsNot() { return isNot; } public final ResolvedExpr getExpr() { return expr; } public final ResolvedGraphLabelExpr getLabelExpr() { return labelExpr; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGraphIsLabeledPredicate accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(expr); visitor.descend(labelExpr); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!DebugStrings.isDefaultValue(isNot)) { fields.add(new DebugStringField("is_not", DebugStrings.toStringImpl(isNot))); } if (expr != null) { fields.add(new DebugStringField("expr", expr)); } if (labelExpr != null) { fields.add(new DebugStringField("label_expr", labelExpr)); } } } /** * This statement: * UNDROP [IF NOT EXISTS] * FOR SYSTEM_TIME AS OF [] * [OPTIONS (name=value, ...)]; * *

is a string identifier for the entity to be * undroped. Currently, only 'SCHEMA' object is supported. * *

is a vector giving the identifier path for the object to * be undropped. * *

if set, skip the undrop if the resource already * exists. * *

specifies point in time from which entity is to * be undropped. * *

contains engine-specific options associated with the schema. */ public static final class ResolvedUndropStmt extends ResolvedStatement { private final String schemaObjectKind; private final boolean isIfNotExists; private final ImmutableList namePath; private final ResolvedExpr forSystemTimeExpr; private final ImmutableList optionList; ResolvedUndropStmt(ResolvedUndropStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); schemaObjectKind = proto.getSchemaObjectKind(); isIfNotExists = proto.getIsIfNotExists(); namePath = ImmutableList.copyOf(proto.getNamePathList()); if (proto.hasForSystemTimeExpr()) { forSystemTimeExpr = ResolvedExpr.deserialize(proto.getForSystemTimeExpr(), helper); } else { forSystemTimeExpr = null; } ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedUndropStmt( ImmutableList hintList, String schemaObjectKind, boolean isIfNotExists, ImmutableList namePath, ResolvedExpr forSystemTimeExpr, ImmutableList optionList) { super( hintList); this.schemaObjectKind = schemaObjectKind; this.isIfNotExists = isIfNotExists; this.namePath = namePath; this.forSystemTimeExpr = forSystemTimeExpr; this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.schemaObjectKind = this.getSchemaObjectKind(); builder.isIfNotExists = this.getIsIfNotExists(); builder.namePath = this.getNamePath(); builder.forSystemTimeExpr = this.getForSystemTimeExpr(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedStatement.Builder { protected String schemaObjectKind = null; protected Boolean isIfNotExists = null; protected ImmutableList namePath = null; protected ResolvedExpr forSystemTimeExpr = null; protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @CanIgnoreReturnValue public Builder setSchemaObjectKind(String v) { this.schemaObjectKind = v; Preconditions.checkNotNull(v, "schemaObjectKind must not be null"); return this; } @CanIgnoreReturnValue public Builder setIsIfNotExists(boolean v) { this.isIfNotExists = v; return this; } @CanIgnoreReturnValue public Builder setNamePath(List v) { this.namePath = ImmutableList.copyOf(v); return this; } @CanIgnoreReturnValue public Builder setForSystemTimeExpr(ResolvedExpr v) { this.forSystemTimeExpr = v; return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedUndropStmt build() { validate(); return new ResolvedUndropStmt( hintList, schemaObjectKind, isIfNotExists, namePath, forSystemTimeExpr, optionList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( schemaObjectKind != null, "schemaObjectKind must be set"); Preconditions.checkArgument( namePath != null, "namePath must be set"); } } public static final ResolvedUndropStmt deserialize( ResolvedUndropStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedUndropStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_UNDROP_STMT; } @Override public final String nodeKindString() { return "UndropStmt"; } /** * 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(); ResolvedUndropStmtProto.Builder childBuilder = ResolvedUndropStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedUndropStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedUndropStmtProto.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, ResolvedUndropStmtProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedStatementProto parent = (ResolvedStatementProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // schemaObjectKind is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setSchemaObjectKind(this.getSchemaObjectKind()); // 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()); // 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()); // 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()); } // 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 getSchemaObjectKind() { return schemaObjectKind; } public final boolean getIsIfNotExists() { return isIfNotExists; } public final ImmutableList getNamePath() { return namePath; } public final ResolvedExpr getForSystemTimeExpr() { return forSystemTimeExpr; } public final ImmutableList getOptionList() { return optionList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedUndropStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(forSystemTimeExpr); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("schema_object_kind", DebugStrings.toStringImpl(schemaObjectKind))); } if (!DebugStrings.isDefaultValue(isIfNotExists)) { fields.add(new DebugStringField("is_if_not_exists", DebugStrings.toStringImpl(isIfNotExists))); } { fields.add(new DebugStringField("name_path", DebugStrings.toStringImpl(namePath))); } if (forSystemTimeExpr != null) { fields.add(new DebugStringField("for_system_time_expr", forSystemTimeExpr)); } if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This argument represents the identity column clause for a generated * column: * GENERATED AS IDENTITY ( * [ START WITH ] * [ INCREMENT BY ] * [ MAXVALUE ] * [ MINVALUE ] * [ CYCLE | NO CYCLE] * ) * If attributes are not specified, the resolver fills in the fields using * default values. * Note: Only integer-typed columns can be identity columns. * *

`start_with_value` is the start/first value generated for the column. * *

`increment_by_value` is the minimum difference between two successive * generated values. * - Can be negative or positive but not 0. * *

`max_value` is the maximum value that can be generated in the column. * *

`min_value` is the minimum value that can be generated in the column. * *

`cycling_enabled`: If true, the generated identity value will cycle around * after overflow, when `min_value` or `max_value` is exceeded. * *

See (broken link). */ public static final class ResolvedIdentityColumnInfo extends ResolvedArgument { private final Value startWithValue; private final Value incrementByValue; private final Value maxValue; private final Value minValue; private final boolean cyclingEnabled; ResolvedIdentityColumnInfo(ResolvedIdentityColumnInfoProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); startWithValue = helper.deserialize(proto.getStartWithValue()); incrementByValue = helper.deserialize(proto.getIncrementByValue()); maxValue = helper.deserialize(proto.getMaxValue()); minValue = helper.deserialize(proto.getMinValue()); cyclingEnabled = proto.getCyclingEnabled(); } ResolvedIdentityColumnInfo( Value startWithValue, Value incrementByValue, Value maxValue, Value minValue, boolean cyclingEnabled) { super(); this.startWithValue = startWithValue; this.incrementByValue = incrementByValue; this.maxValue = maxValue; this.minValue = minValue; this.cyclingEnabled = cyclingEnabled; } @Override public Builder toBuilder() { Builder builder = builder(); builder.startWithValue = this.getStartWithValue(); builder.incrementByValue = this.getIncrementByValue(); builder.maxValue = this.getMaxValue(); builder.minValue = this.getMinValue(); builder.cyclingEnabled = this.getCyclingEnabled(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected Value startWithValue = null; protected Value incrementByValue = null; protected Value maxValue = null; protected Value minValue = null; protected Boolean cyclingEnabled = null; private Builder() {} @CanIgnoreReturnValue public Builder setStartWithValue(Value v) { this.startWithValue = v; Preconditions.checkNotNull(v, "startWithValue must not be null"); return this; } @CanIgnoreReturnValue public Builder setIncrementByValue(Value v) { this.incrementByValue = v; Preconditions.checkNotNull(v, "incrementByValue must not be null"); return this; } @CanIgnoreReturnValue public Builder setMaxValue(Value v) { this.maxValue = v; Preconditions.checkNotNull(v, "maxValue must not be null"); return this; } @CanIgnoreReturnValue public Builder setMinValue(Value v) { this.minValue = v; Preconditions.checkNotNull(v, "minValue must not be null"); return this; } @CanIgnoreReturnValue public Builder setCyclingEnabled(boolean v) { this.cyclingEnabled = v; return this; } @Override public final ResolvedIdentityColumnInfo build() { validate(); return new ResolvedIdentityColumnInfo( startWithValue, incrementByValue, maxValue, minValue, cyclingEnabled); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( startWithValue != null, "startWithValue must be set"); Preconditions.checkArgument( incrementByValue != null, "incrementByValue must be set"); Preconditions.checkArgument( maxValue != null, "maxValue must be set"); Preconditions.checkArgument( minValue != null, "minValue must be set"); Preconditions.checkArgument( cyclingEnabled != null, "cyclingEnabled must be set"); } } public static final ResolvedIdentityColumnInfo deserialize( ResolvedIdentityColumnInfoProto proto, AbstractDeserializationHelper helper) { return new ResolvedIdentityColumnInfo(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_IDENTITY_COLUMN_INFO; } @Override public final String nodeKindString() { return "IdentityColumnInfo"; } /** * 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(); ResolvedIdentityColumnInfoProto.Builder childBuilder = ResolvedIdentityColumnInfoProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedIdentityColumnInfoNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedIdentityColumnInfoProto.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, ResolvedIdentityColumnInfoProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // startWithValue is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getStartWithValue() != null) { proto.setStartWithValue( ResolvedNodes.serialize(this.getStartWithValue(), fileDescriptorSetsBuilder)); } // incrementByValue is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getIncrementByValue() != null) { proto.setIncrementByValue( ResolvedNodes.serialize(this.getIncrementByValue(), fileDescriptorSetsBuilder)); } // maxValue is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getMaxValue() != null) { proto.setMaxValue( ResolvedNodes.serialize(this.getMaxValue(), fileDescriptorSetsBuilder)); } // minValue is a leaf type that requires a helper method to serialize. // (see scalar types in (broken link).py for more information.) if (this.getMinValue() != null) { proto.setMinValue( ResolvedNodes.serialize(this.getMinValue(), fileDescriptorSetsBuilder)); } // cyclingEnabled is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setCyclingEnabled(this.getCyclingEnabled()); } public final Value getStartWithValue() { return startWithValue; } public final Value getIncrementByValue() { return incrementByValue; } public final Value getMaxValue() { return maxValue; } public final Value getMinValue() { return minValue; } public final boolean getCyclingEnabled() { return cyclingEnabled; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedIdentityColumnInfo accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("start_with_value", DebugStrings.toStringImpl(startWithValue))); } { fields.add(new DebugStringField("increment_by_value", DebugStrings.toStringImpl(incrementByValue))); } { fields.add(new DebugStringField("max_value", DebugStrings.toStringImpl(maxValue))); } { fields.add(new DebugStringField("min_value", DebugStrings.toStringImpl(minValue))); } { fields.add(new DebugStringField("cycling_enabled", DebugStrings.toStringImpl(cyclingEnabled))); } } } /** * This represents the pipe STATIC_DESCRIBE operator, which is controlled by * FEATURE_PIPE_STATIC_DESCRIBE. * *

This scan is a no-op, that just stores the describe_text produced to show * the intermediate schema where this operator occurred. * *

This describe_text is displayed in resolved AST DebugStrings (which is * used internally in analyzer tests), and is also meant to be displayed * through some engine-specific side-channel at query prepare time. */ public static final class ResolvedStaticDescribeScan extends ResolvedScan { private final ResolvedScan inputScan; private final String describeText; ResolvedStaticDescribeScan(ResolvedStaticDescribeScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } describeText = proto.getDescribeText(); } ResolvedStaticDescribeScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, String describeText) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.describeText = describeText; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.describeText = this.getDescribeText(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected String describeText = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } /** * Note: this method propagates the 'isOrdered' field from {@param v}. * To override this, call setIsOrdered explicitly after calling this * method. */ @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); setIsOrdered(v.getIsOrdered()); return this; } @CanIgnoreReturnValue public Builder setDescribeText(String v) { this.describeText = v; return this; } @Override public final ResolvedStaticDescribeScan build() { validate(); return new ResolvedStaticDescribeScan( columnList, hintList, isOrdered, nodeSource, inputScan, describeText); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); } } public static final ResolvedStaticDescribeScan deserialize( ResolvedStaticDescribeScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedStaticDescribeScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_STATIC_DESCRIBE_SCAN; } @Override public final String nodeKindString() { return "StaticDescribeScan"; } /** * 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(); ResolvedStaticDescribeScanProto.Builder childBuilder = ResolvedStaticDescribeScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedStaticDescribeScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedStaticDescribeScanProto.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, ResolvedStaticDescribeScanProto.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()); } // describeText is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setDescribeText(this.getDescribeText()); } public final ResolvedScan getInputScan() { return inputScan; } public final String getDescribeText() { return describeText; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedStaticDescribeScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); DebugStrings.collectDebugStringFields(this, fields); } public String getNameForDebugString() { return DebugStrings.getNameForDebugString(this); } } /** * This represents the pipe ASSERT operator, which is controlled by * FEATURE_PIPE_ASSERT. * *

`condition` is a boolean expression. * `message` is a string expression. * *

`condition` is computed for each row. If it does not return true, * the assertion fails. Then `message` is evaluated and used as part * of the error message, following something like "Assert failed: ". */ public static final class ResolvedAssertScan extends ResolvedScan { private final ResolvedScan inputScan; private final ResolvedExpr condition; private final ResolvedExpr message; ResolvedAssertScan(ResolvedAssertScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } if (proto.hasCondition()) { condition = ResolvedExpr.deserialize(proto.getCondition(), helper); } else { condition = null; } if (proto.hasMessage()) { message = ResolvedExpr.deserialize(proto.getMessage(), helper); } else { message = null; } } ResolvedAssertScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ResolvedExpr condition, ResolvedExpr message) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.condition = condition; this.message = message; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.condition = this.getCondition(); builder.message = this.getMessage(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ResolvedExpr condition = null; protected ResolvedExpr message = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setCondition(ResolvedExpr v) { this.condition = v; Preconditions.checkNotNull(v, "condition must not be null"); return this; } @CanIgnoreReturnValue public Builder setMessage(ResolvedExpr v) { this.message = v; Preconditions.checkNotNull(v, "message must not be null"); return this; } @Override public final ResolvedAssertScan build() { validate(); return new ResolvedAssertScan( columnList, hintList, isOrdered, nodeSource, inputScan, condition, message); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( condition != null, "condition must be set"); Preconditions.checkArgument( message != null, "message must be set"); } } public static final ResolvedAssertScan deserialize( ResolvedAssertScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedAssertScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ASSERT_SCAN; } @Override public final String nodeKindString() { return "AssertScan"; } /** * 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(); ResolvedAssertScanProto.Builder childBuilder = ResolvedAssertScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAssertScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAssertScanProto.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, ResolvedAssertScanProto.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()); } // condition is an AST node. Call its serialization chain. if (this.getCondition() != null) { AnyResolvedExprProto.Builder conditionBuilder = AnyResolvedExprProto.newBuilder(); this.getCondition().serialize( fileDescriptorSetsBuilder, conditionBuilder); proto.setCondition( conditionBuilder.build()); } // message is an AST node. Call its serialization chain. if (this.getMessage() != null) { AnyResolvedExprProto.Builder messageBuilder = AnyResolvedExprProto.newBuilder(); this.getMessage().serialize( fileDescriptorSetsBuilder, messageBuilder); proto.setMessage( messageBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ResolvedExpr getCondition() { return condition; } public final ResolvedExpr getMessage() { return message; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedAssertScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(condition); visitor.descend(message); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (condition != null) { fields.add(new DebugStringField("condition", condition)); } if (message != null) { fields.add(new DebugStringField("message", message)); } } } /** * This represents the pipe ABSL_LOG operator, which is controlled by * FEATURE_PIPE_LOG. * *

Execute `subpipeline` over `input_scan` and send its output to an * implementation-defined log. * *

`output_schema` describes the visible schema of the output to send to * the log. (This is not the output of the ResolvedLogScan in the query.) * *

In the main query flow, ResolvedLogScan is a no-op and just returns * the result from `input_scan` unchanged. */ public static final class ResolvedLogScan extends ResolvedScan { private final ResolvedScan inputScan; private final ResolvedSubpipeline subpipeline; private final ResolvedOutputSchema outputSchema; ResolvedLogScan(ResolvedLogScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } if (proto.hasSubpipeline()) { subpipeline = ResolvedSubpipeline.deserialize(proto.getSubpipeline(), helper); } else { subpipeline = null; } if (proto.hasOutputSchema()) { outputSchema = ResolvedOutputSchema.deserialize(proto.getOutputSchema(), helper); } else { outputSchema = null; } } ResolvedLogScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ResolvedSubpipeline subpipeline, ResolvedOutputSchema outputSchema) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.subpipeline = subpipeline; this.outputSchema = outputSchema; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.subpipeline = this.getSubpipeline(); builder.outputSchema = this.getOutputSchema(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ResolvedSubpipeline subpipeline = null; protected ResolvedOutputSchema outputSchema = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } /** * Note: this method propagates the 'isOrdered' field from {@param v}. * To override this, call setIsOrdered explicitly after calling this * method. */ @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); setIsOrdered(v.getIsOrdered()); return this; } @CanIgnoreReturnValue public Builder setSubpipeline(ResolvedSubpipeline v) { this.subpipeline = v; Preconditions.checkNotNull(v, "subpipeline must not be null"); return this; } @CanIgnoreReturnValue public Builder setOutputSchema(ResolvedOutputSchema v) { this.outputSchema = v; Preconditions.checkNotNull(v, "outputSchema must not be null"); return this; } @Override public final ResolvedLogScan build() { validate(); return new ResolvedLogScan( columnList, hintList, isOrdered, nodeSource, inputScan, subpipeline, outputSchema); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( subpipeline != null, "subpipeline must be set"); Preconditions.checkArgument( outputSchema != null, "outputSchema must be set"); } } public static final ResolvedLogScan deserialize( ResolvedLogScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedLogScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_LOG_SCAN; } @Override public final String nodeKindString() { return "LogScan"; } /** * 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(); ResolvedLogScanProto.Builder childBuilder = ResolvedLogScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedLogScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedLogScanProto.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, ResolvedLogScanProto.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()); } // subpipeline is an AST node. Call its serialization chain. if (this.getSubpipeline() != null) { ResolvedSubpipelineProto.Builder subpipelineBuilder = ResolvedSubpipelineProto.newBuilder(); this.getSubpipeline().serialize( fileDescriptorSetsBuilder, subpipelineBuilder); proto.setSubpipeline( subpipelineBuilder.build()); } // outputSchema is an AST node. Call its serialization chain. if (this.getOutputSchema() != null) { ResolvedOutputSchemaProto.Builder outputSchemaBuilder = ResolvedOutputSchemaProto.newBuilder(); this.getOutputSchema().serialize( fileDescriptorSetsBuilder, outputSchemaBuilder); proto.setOutputSchema( outputSchemaBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ResolvedSubpipeline getSubpipeline() { return subpipeline; } public final ResolvedOutputSchema getOutputSchema() { return outputSchema; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedLogScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(subpipeline); visitor.descend(outputSchema); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (subpipeline != null) { fields.add(new DebugStringField("subpipeline", subpipeline)); } if (outputSchema != null) { fields.add(new DebugStringField("output_schema", outputSchema)); } } } /** * This represents the pipe IF operator, which is controlled by * FEATURE_PIPE_IF. See (broken link). * *

`if_case_list` must have at least one element with a `condition`. * If there's an ELSE case, if will be last and will have no `condition`. * *

`selected_case` indicates the chosen case and must be a valid index into * `if_case_list`. `selected_case` is -1 if no case is selected and there's * no ELSE case. * *

The constant `condition` for `selected_case` must evaluate to true unless * it's the ELSE case. All preceding `condition` expressions must evaluate * to non-true values. (Later `condition` expressions could return errors.) * *

The selected case includes a valid resolved `subpipeline` that takes * `input_scan` as its input table. * *

Execution semantics: * Only the selected case runs. The condition expressions have already been * evaluated statically at analysis time so are not evaluated at runtime. * If `selected_case` is -1, this scan is a no-op. * *

The subpipeline for the selected case runs over `input_scan`. * Its output is this node's output. * This node's `column_list` must be a subset of the subpipeline's final * column list. * *

`if_case_list` is ignorable because if `selected_case` is -1, it's * not necessary to look at any cases. */ public static final class ResolvedPipeIfScan extends ResolvedScan { private final ResolvedScan inputScan; private final long selectedCase; private final ImmutableList ifCaseList; ResolvedPipeIfScan(ResolvedPipeIfScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } selectedCase = proto.getSelectedCase(); ImmutableList.Builder ifCaseListBuilder = ImmutableList.builder(); for (ResolvedPipeIfCaseProto element : proto.getIfCaseListList()) { ifCaseListBuilder .add(ResolvedPipeIfCase.deserialize(element, helper)); } ifCaseList = ifCaseListBuilder.build(); } ResolvedPipeIfScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, long selectedCase, ImmutableList ifCaseList) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.selectedCase = selectedCase; this.ifCaseList = ifCaseList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.selectedCase = this.getSelectedCase(); builder.ifCaseList = this.getIfCaseList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected Long selectedCase = null; protected ImmutableList ifCaseList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setSelectedCase(long v) { this.selectedCase = v; return this; } @CanIgnoreReturnValue public Builder setIfCaseList(List v) { this.ifCaseList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedPipeIfScan build() { validate(); return new ResolvedPipeIfScan( columnList, hintList, isOrdered, nodeSource, inputScan, selectedCase, ifCaseList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( selectedCase != null, "selectedCase must be set"); } } public static final ResolvedPipeIfScan deserialize( ResolvedPipeIfScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedPipeIfScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PIPE_IF_SCAN; } @Override public final String nodeKindString() { return "PipeIfScan"; } /** * 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(); ResolvedPipeIfScanProto.Builder childBuilder = ResolvedPipeIfScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedPipeIfScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedPipeIfScanProto.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, ResolvedPipeIfScanProto.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()); } // selectedCase is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setSelectedCase(this.getSelectedCase()); // ifCaseList is a collection of AST nodes. Serialize each of them. ImmutableList ifCaseLists = this.getIfCaseList(); for (ResolvedPipeIfCase element : ifCaseLists) { ResolvedPipeIfCaseProto.Builder ifCaseListBuilder = ResolvedPipeIfCaseProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, ifCaseListBuilder); proto.addIfCaseList(ifCaseListBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final long getSelectedCase() { return selectedCase; } public final ImmutableList getIfCaseList() { return ifCaseList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedPipeIfScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(ifCaseList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } { fields.add(new DebugStringField("selected_case", DebugStrings.toStringImpl(selectedCase))); } if (!ifCaseList.isEmpty()) { fields.add(new DebugStringField("if_case_list", ifCaseList)); } } } /** * This represents one case in a ResolvedPipeIf. * *

`condition` and `subpipeline_sql` must be present for all cases except * the last case (if it's an ELSE case). * `condition` must be present except on the ELSE case. * `subpipeline_sql` must be present for all cases. * *

Where `condition` is present, it must be a valid boolean constant * expression. * *

`subpipeline_sql` gives the SQL for the subpipeline, including the * wrapping parentheses. This is required even for the selected case * because the SQLBuilder currently relies on it. * *

`subpipeline_sql` for non-selected cases doesn't have to be resolvable * but should be parsable. * *

`subpipeline` must be present for the selected case, and can optionally * be present for other cases (only when the SQL is valid). * *

`condition` is ignorable because conditions are evaluated at analysis time * and the case to run has already been chosen. * *

`subpipeline` is ignorable because it doesn't need to be consumed in the * non-selected cases. */ public static final class ResolvedPipeIfCase extends ResolvedArgument { private final ResolvedExpr condition; private final String subpipelineSql; private final ResolvedSubpipeline subpipeline; ResolvedPipeIfCase(ResolvedPipeIfCaseProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasCondition()) { condition = ResolvedExpr.deserialize(proto.getCondition(), helper); } else { condition = null; } subpipelineSql = proto.getSubpipelineSql(); if (proto.hasSubpipeline()) { subpipeline = ResolvedSubpipeline.deserialize(proto.getSubpipeline(), helper); } else { subpipeline = null; } } ResolvedPipeIfCase( ResolvedExpr condition, String subpipelineSql, ResolvedSubpipeline subpipeline) { super(); this.condition = condition; this.subpipelineSql = subpipelineSql; this.subpipeline = subpipeline; } @Override public Builder toBuilder() { Builder builder = builder(); builder.condition = this.getCondition(); builder.subpipelineSql = this.getSubpipelineSql(); builder.subpipeline = this.getSubpipeline(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedExpr condition = null; protected String subpipelineSql = null; protected ResolvedSubpipeline subpipeline = null; private Builder() {} @CanIgnoreReturnValue public Builder setCondition(ResolvedExpr v) { this.condition = v; return this; } @CanIgnoreReturnValue public Builder setSubpipelineSql(String v) { this.subpipelineSql = v; return this; } @CanIgnoreReturnValue public Builder setSubpipeline(ResolvedSubpipeline v) { this.subpipeline = v; return this; } @Override public final ResolvedPipeIfCase build() { validate(); return new ResolvedPipeIfCase( condition, subpipelineSql, subpipeline); } @Override protected void validate() { super.validate(); } } public static final ResolvedPipeIfCase deserialize( ResolvedPipeIfCaseProto proto, AbstractDeserializationHelper helper) { return new ResolvedPipeIfCase(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PIPE_IF_CASE; } @Override public final String nodeKindString() { return "PipeIfCase"; } /** * 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(); ResolvedPipeIfCaseProto.Builder childBuilder = ResolvedPipeIfCaseProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedPipeIfCaseNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedPipeIfCaseProto.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, ResolvedPipeIfCaseProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // condition is an AST node. Call its serialization chain. if (this.getCondition() != null) { AnyResolvedExprProto.Builder conditionBuilder = AnyResolvedExprProto.newBuilder(); this.getCondition().serialize( fileDescriptorSetsBuilder, conditionBuilder); proto.setCondition( conditionBuilder.build()); } // subpipelineSql is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setSubpipelineSql(this.getSubpipelineSql()); // subpipeline is an AST node. Call its serialization chain. if (this.getSubpipeline() != null) { ResolvedSubpipelineProto.Builder subpipelineBuilder = ResolvedSubpipelineProto.newBuilder(); this.getSubpipeline().serialize( fileDescriptorSetsBuilder, subpipelineBuilder); proto.setSubpipeline( subpipelineBuilder.build()); } } public final ResolvedExpr getCondition() { return condition; } public final String getSubpipelineSql() { return subpipelineSql; } public final ResolvedSubpipeline getSubpipeline() { return subpipeline; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedPipeIfCase accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(condition); visitor.descend(subpipeline); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (condition != null) { fields.add(new DebugStringField("condition", condition)); } if (!DebugStrings.isDefaultValue(subpipelineSql)) { fields.add(new DebugStringField("subpipeline_sql", DebugStrings.toStringImpl(subpipelineSql))); } if (subpipeline != null) { fields.add(new DebugStringField("subpipeline", subpipeline)); } } } /** * This represents the pipe FORK operator, which is controlled by * FEATURE_PIPE_FORK. See (broken link). * *

This only occurs inside ResolvedGeneralizedQueryStmts, so that statement * must be enabled in SupportedStatementKinds. */ public static final class ResolvedPipeForkScan extends ResolvedScan { private final ResolvedScan inputScan; private final ImmutableList subpipelineList; ResolvedPipeForkScan(ResolvedPipeForkScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } ImmutableList.Builder subpipelineListBuilder = ImmutableList.builder(); for (ResolvedGeneralizedQuerySubpipelineProto element : proto.getSubpipelineListList()) { subpipelineListBuilder .add(ResolvedGeneralizedQuerySubpipeline.deserialize(element, helper)); } subpipelineList = subpipelineListBuilder.build(); } ResolvedPipeForkScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ImmutableList subpipelineList) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.subpipelineList = subpipelineList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.subpipelineList = this.getSubpipelineList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ImmutableList subpipelineList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setSubpipelineList(List v) { this.subpipelineList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedPipeForkScan build() { validate(); return new ResolvedPipeForkScan( columnList, hintList, isOrdered, nodeSource, inputScan, subpipelineList); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( subpipelineList != null, "subpipelineList must be set"); } } public static final ResolvedPipeForkScan deserialize( ResolvedPipeForkScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedPipeForkScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PIPE_FORK_SCAN; } @Override public final String nodeKindString() { return "PipeForkScan"; } /** * 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(); ResolvedPipeForkScanProto.Builder childBuilder = ResolvedPipeForkScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedPipeForkScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedPipeForkScanProto.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, ResolvedPipeForkScanProto.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()); } // subpipelineList is a collection of AST nodes. Serialize each of them. ImmutableList subpipelineLists = this.getSubpipelineList(); for (ResolvedGeneralizedQuerySubpipeline element : subpipelineLists) { ResolvedGeneralizedQuerySubpipelineProto.Builder subpipelineListBuilder = ResolvedGeneralizedQuerySubpipelineProto.newBuilder(); element.serialize(fileDescriptorSetsBuilder, subpipelineListBuilder); proto.addSubpipelineList(subpipelineListBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ImmutableList getSubpipelineList() { return subpipelineList; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedPipeForkScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(subpipelineList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (!subpipelineList.isEmpty()) { fields.add(new DebugStringField("subpipeline_list", subpipelineList)); } } } /** * This represents the pipe EXPORT DATA operator, which is controlled by * FEATURE_PIPE_EXPORT_DATA. See (broken link). * *

This only occurs inside ResolvedGeneralizedQueryStmts, so that statement * must be enabled in SupportedStatementKinds. */ public static final class ResolvedPipeExportDataScan extends ResolvedScan { private final ResolvedScan inputScan; private final ResolvedExportDataStmt exportDataStmt; ResolvedPipeExportDataScan(ResolvedPipeExportDataScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } if (proto.hasExportDataStmt()) { exportDataStmt = ResolvedExportDataStmt.deserialize(proto.getExportDataStmt(), helper); } else { exportDataStmt = null; } } ResolvedPipeExportDataScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan, ResolvedExportDataStmt exportDataStmt) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; this.exportDataStmt = exportDataStmt; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); builder.exportDataStmt = this.getExportDataStmt(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; protected ResolvedExportDataStmt exportDataStmt = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); return this; } @CanIgnoreReturnValue public Builder setExportDataStmt(ResolvedExportDataStmt v) { this.exportDataStmt = v; Preconditions.checkNotNull(v, "exportDataStmt must not be null"); return this; } @Override public final ResolvedPipeExportDataScan build() { validate(); return new ResolvedPipeExportDataScan( columnList, hintList, isOrdered, nodeSource, inputScan, exportDataStmt); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); Preconditions.checkArgument( exportDataStmt != null, "exportDataStmt must be set"); } } public static final ResolvedPipeExportDataScan deserialize( ResolvedPipeExportDataScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedPipeExportDataScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_PIPE_EXPORT_DATA_SCAN; } @Override public final String nodeKindString() { return "PipeExportDataScan"; } /** * 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(); ResolvedPipeExportDataScanProto.Builder childBuilder = ResolvedPipeExportDataScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedPipeExportDataScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedPipeExportDataScanProto.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, ResolvedPipeExportDataScanProto.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()); } // exportDataStmt is an AST node. Call its serialization chain. if (this.getExportDataStmt() != null) { ResolvedExportDataStmtProto.Builder exportDataStmtBuilder = ResolvedExportDataStmtProto.newBuilder(); this.getExportDataStmt().serialize( fileDescriptorSetsBuilder, exportDataStmtBuilder); proto.setExportDataStmt( exportDataStmtBuilder.build()); } } public final ResolvedScan getInputScan() { return inputScan; } public final ResolvedExportDataStmt getExportDataStmt() { return exportDataStmt; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedPipeExportDataScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); visitor.descend(exportDataStmt); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } if (exportDataStmt != null) { fields.add(new DebugStringField("export_data_stmt", exportDataStmt)); } } } /** * This represents a subpipeline. * These occur inside various pipe operators, expressing a subpipeline of * pipe operators to apply on some input table. * See (broken link). * *

The operator that contains this ResolvedSubpipeline defines how it's * being used and what table is passed in. Most commonly, this is used * inside pipe operator scans, and is passed the `input_scan` of the * containing ResolvedScan. When some other intermediate table is passed to * the subpipeline, that will be documented in the containing node. * *

Inside `scan`, there must be exactly one instance of * ResolvedSubpipelineInputScan as a leaf scan receiving the subpipeline's * input table. That scan's column_list includes a subset of columns * available from the input table provided to this ResolvedSubpipeline. * *

ResolvedSubpipeline is like the final subquery in a ResolvedWithScan. * The ResolvedSubpipelineInputScan is like the ResolvedWithRefScan. * The node containing this ResolvedSubpipeline is like the ResolvedWithScan * and has to define the CTE-like table that will be referenced. */ public static final class ResolvedSubpipeline extends ResolvedArgument { private final ResolvedScan scan; ResolvedSubpipeline(ResolvedSubpipelineProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasScan()) { scan = ResolvedScan.deserialize(proto.getScan(), helper); } else { scan = null; } } ResolvedSubpipeline( ResolvedScan scan) { super(); this.scan = scan; } @Override public Builder toBuilder() { Builder builder = builder(); builder.scan = this.getScan(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedScan scan = null; private Builder() {} @CanIgnoreReturnValue public Builder setScan(ResolvedScan v) { this.scan = v; Preconditions.checkNotNull(v, "scan must not be null"); return this; } @Override public final ResolvedSubpipeline build() { validate(); return new ResolvedSubpipeline( scan); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( scan != null, "scan must be set"); } } public static final ResolvedSubpipeline deserialize( ResolvedSubpipelineProto proto, AbstractDeserializationHelper helper) { return new ResolvedSubpipeline(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SUBPIPELINE; } @Override public final String nodeKindString() { return "Subpipeline"; } /** * 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(); ResolvedSubpipelineProto.Builder childBuilder = ResolvedSubpipelineProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSubpipelineNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSubpipelineProto.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, ResolvedSubpipelineProto.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()); } } public final ResolvedScan getScan() { return scan; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedSubpipeline accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(scan); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (scan != null) { fields.add(new DebugStringField("scan", scan)); } } } /** * This is the scan inside a ResolvedSubpipeline representing the initial * input table passed into the subpipeline. This works like a CTE in WITH. * *

The node containing the ResolvedSubpipeline (which is like a * ResolvedWithScan) specifies what table this is. Often it's a table that * just gets a copy of the node's `input_scan`, to pass through to the * subpipeline. * *

The ResolvedSubpipelineInputScan is like a ResolvedWithRefScan, doing the * scan of that specified table inside the subpupline query. * *

The `column_list` columns are a subset of columns available on that * input table. */ public static final class ResolvedSubpipelineInputScan extends ResolvedScan { ResolvedSubpipelineInputScan(ResolvedSubpipelineInputScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedSubpipelineInputScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource) { super( columnList, hintList, isOrdered, nodeSource); } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } @Override public final ResolvedSubpipelineInputScan build() { validate(); return new ResolvedSubpipelineInputScan( columnList, hintList, isOrdered, nodeSource); } @Override protected void validate() { super.validate(); } } public static final ResolvedSubpipelineInputScan deserialize( ResolvedSubpipelineInputScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedSubpipelineInputScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_SUBPIPELINE_INPUT_SCAN; } @Override public final String nodeKindString() { return "SubpipelineInputScan"; } /** * 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(); ResolvedSubpipelineInputScanProto.Builder childBuilder = ResolvedSubpipelineInputScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedSubpipelineInputScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedSubpipelineInputScanProto.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, ResolvedSubpipelineInputScanProto.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 public ResolvedSubpipelineInputScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * This represents a subpipeline that is part of a ResolvedGeneralizedQueryStmt * and could produce an output table or a statement side-effect. * This node can only occur inside a ResolvedGeneralizedQueryStmt. * *

These subpipelines occur inside operators like FORK that create * generalized query shapes. See (broken link). * *

`output_schema` is present if this subpipeline produces a final output * table to be returned as part of the ResolvedGeneralizedQueryStmt, and * provides the schema of that table. */ public static final class ResolvedGeneralizedQuerySubpipeline extends ResolvedArgument { private final ResolvedSubpipeline subpipeline; private final ResolvedOutputSchema outputSchema; ResolvedGeneralizedQuerySubpipeline(ResolvedGeneralizedQuerySubpipelineProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasSubpipeline()) { subpipeline = ResolvedSubpipeline.deserialize(proto.getSubpipeline(), helper); } else { subpipeline = null; } if (proto.hasOutputSchema()) { outputSchema = ResolvedOutputSchema.deserialize(proto.getOutputSchema(), helper); } else { outputSchema = null; } } ResolvedGeneralizedQuerySubpipeline( ResolvedSubpipeline subpipeline, ResolvedOutputSchema outputSchema) { super(); this.subpipeline = subpipeline; this.outputSchema = outputSchema; } @Override public Builder toBuilder() { Builder builder = builder(); builder.subpipeline = this.getSubpipeline(); builder.outputSchema = this.getOutputSchema(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected ResolvedSubpipeline subpipeline = null; protected ResolvedOutputSchema outputSchema = null; private Builder() {} @CanIgnoreReturnValue public Builder setSubpipeline(ResolvedSubpipeline v) { this.subpipeline = v; Preconditions.checkNotNull(v, "subpipeline must not be null"); return this; } @CanIgnoreReturnValue public Builder setOutputSchema(ResolvedOutputSchema v) { this.outputSchema = v; Preconditions.checkNotNull(v, "outputSchema must not be null"); return this; } @Override public final ResolvedGeneralizedQuerySubpipeline build() { validate(); return new ResolvedGeneralizedQuerySubpipeline( subpipeline, outputSchema); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( subpipeline != null, "subpipeline must be set"); Preconditions.checkArgument( outputSchema != null, "outputSchema must be set"); } } public static final ResolvedGeneralizedQuerySubpipeline deserialize( ResolvedGeneralizedQuerySubpipelineProto proto, AbstractDeserializationHelper helper) { return new ResolvedGeneralizedQuerySubpipeline(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_GENERALIZED_QUERY_SUBPIPELINE; } @Override public final String nodeKindString() { return "GeneralizedQuerySubpipeline"; } /** * 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(); ResolvedGeneralizedQuerySubpipelineProto.Builder childBuilder = ResolvedGeneralizedQuerySubpipelineProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedGeneralizedQuerySubpipelineNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedGeneralizedQuerySubpipelineProto.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, ResolvedGeneralizedQuerySubpipelineProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // subpipeline is an AST node. Call its serialization chain. if (this.getSubpipeline() != null) { ResolvedSubpipelineProto.Builder subpipelineBuilder = ResolvedSubpipelineProto.newBuilder(); this.getSubpipeline().serialize( fileDescriptorSetsBuilder, subpipelineBuilder); proto.setSubpipeline( subpipelineBuilder.build()); } // outputSchema is an AST node. Call its serialization chain. if (this.getOutputSchema() != null) { ResolvedOutputSchemaProto.Builder outputSchemaBuilder = ResolvedOutputSchemaProto.newBuilder(); this.getOutputSchema().serialize( fileDescriptorSetsBuilder, outputSchemaBuilder); proto.setOutputSchema( outputSchemaBuilder.build()); } } public final ResolvedSubpipeline getSubpipeline() { return subpipeline; } public final ResolvedOutputSchema getOutputSchema() { return outputSchema; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedGeneralizedQuerySubpipeline accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(subpipeline); visitor.descend(outputSchema); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (subpipeline != null) { fields.add(new DebugStringField("subpipeline", subpipeline)); } if (outputSchema != null) { fields.add(new DebugStringField("output_schema", outputSchema)); } } } /** * ResolvedBarrierScan marks an optimization barrier during query planning. * It wraps an `input_scan` and ensures `input_scan` is evaluated as if * `input_scan` stands alone; plan transformations that may cause * different observable side effects may not cross the optimization barrier. * *

The output rows of a ResolvedBarrierScan are the same as those of the * `input_scan`, propagating the `is_ordered` property of `input_scan`. * *

The following optimizations are allowed: * * Prune an unused column of a ResolvedBarrierScan. * * Prune the whole ResolvedBarrierScan. * *

This node does not have a corresponding syntax. */ public static final class ResolvedBarrierScan extends ResolvedScan { private final ResolvedScan inputScan; ResolvedBarrierScan(ResolvedBarrierScanProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); if (proto.hasInputScan()) { inputScan = ResolvedScan.deserialize(proto.getInputScan(), helper); } else { inputScan = null; } } ResolvedBarrierScan( ImmutableList columnList, ImmutableList hintList, boolean isOrdered, String nodeSource, ResolvedScan inputScan) { super( columnList, hintList, isOrdered, nodeSource); this.inputScan = inputScan; } @Override public Builder toBuilder() { Builder builder = builder(); builder.columnList = this.getColumnList(); builder.hintList = this.getHintList(); builder.isOrdered = this.getIsOrdered(); builder.nodeSource = this.getNodeSource(); builder.inputScan = this.getInputScan(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedScan.Builder { protected ResolvedScan inputScan = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setColumnList(List v) { super.setColumnList(v); return this; } @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsOrdered(boolean v) { super.setIsOrdered(v); return this; } @Override @CanIgnoreReturnValue public Builder setNodeSource(String v) { super.setNodeSource(v); return this; } /** * Note: this method propagates the 'isOrdered' field from {@param v}. * To override this, call setIsOrdered explicitly after calling this * method. */ @CanIgnoreReturnValue public Builder setInputScan(ResolvedScan v) { this.inputScan = v; Preconditions.checkNotNull(v, "inputScan must not be null"); setIsOrdered(v.getIsOrdered()); return this; } @Override public final ResolvedBarrierScan build() { validate(); return new ResolvedBarrierScan( columnList, hintList, isOrdered, nodeSource, inputScan); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( inputScan != null, "inputScan must be set"); } } public static final ResolvedBarrierScan deserialize( ResolvedBarrierScanProto proto, AbstractDeserializationHelper helper) { return new ResolvedBarrierScan(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_BARRIER_SCAN; } @Override public final String nodeKindString() { return "BarrierScan"; } /** * 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(); ResolvedBarrierScanProto.Builder childBuilder = ResolvedBarrierScanProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedBarrierScanNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedBarrierScanProto.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, ResolvedBarrierScanProto.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()); } } public final ResolvedScan getInputScan() { return inputScan; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedBarrierScan accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(inputScan); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (inputScan != null) { fields.add(new DebugStringField("input_scan", inputScan)); } } } /** * This statement: * CREATE [OR REPLACE] [TEMP] CONNECTION * [IF NOT EXISTS] [OPTIONS (name=value, ...)] * *

builds a new connection based on the inputs provided via the * the OPTIONS field. * *

is the name of the fully qualified connection. * is the list of options for the connection. */ public static final class ResolvedCreateConnectionStmt extends ResolvedCreateStatement { private final ImmutableList optionList; ResolvedCreateConnectionStmt(ResolvedCreateConnectionStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); ImmutableList.Builder optionListBuilder = ImmutableList.builder(); for (ResolvedOptionProto element : proto.getOptionListList()) { optionListBuilder .add(ResolvedOption.deserialize(element, helper)); } optionList = optionListBuilder.build(); } ResolvedCreateConnectionStmt( ImmutableList hintList, ImmutableList namePath, CreateScope createScope, CreateMode createMode, ImmutableList optionList) { super( hintList, namePath, createScope, createMode); this.optionList = optionList; } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.createScope = this.getCreateScope(); builder.createMode = this.getCreateMode(); builder.optionList = this.getOptionList(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedCreateStatement.Builder { protected ImmutableList optionList = null; private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateScope(CreateScope v) { super.setCreateScope(v); return this; } @Override @CanIgnoreReturnValue public Builder setCreateMode(CreateMode v) { super.setCreateMode(v); return this; } @CanIgnoreReturnValue public Builder setOptionList(List v) { this.optionList = ImmutableList.copyOf(v); return this; } @Override public final ResolvedCreateConnectionStmt build() { validate(); return new ResolvedCreateConnectionStmt( hintList, namePath, createScope, createMode, optionList); } @Override protected void validate() { super.validate(); } } public static final ResolvedCreateConnectionStmt deserialize( ResolvedCreateConnectionStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedCreateConnectionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_CREATE_CONNECTION_STMT; } @Override public final String nodeKindString() { return "CreateConnectionStmt"; } /** * 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(); ResolvedCreateConnectionStmtProto.Builder childBuilder = ResolvedCreateConnectionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedCreateConnectionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedCreateConnectionStmtProto.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, ResolvedCreateConnectionStmtProto.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 public ResolvedCreateConnectionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); visitor.descend(optionList); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); if (!optionList.isEmpty()) { fields.add(new DebugStringField("option_list", optionList)); } } } /** * This statement: * ALTER CONNECTION [IF EXISTS] SET OPTIONS(...) */ public static final class ResolvedAlterConnectionStmt extends ResolvedAlterObjectStmt { ResolvedAlterConnectionStmt(ResolvedAlterConnectionStmtProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); } ResolvedAlterConnectionStmt( ImmutableList hintList, ImmutableList namePath, ImmutableList alterActionList, boolean isIfExists) { super( hintList, namePath, alterActionList, isIfExists); } @Override public Builder toBuilder() { Builder builder = builder(); builder.hintList = this.getHintList(); builder.namePath = this.getNamePath(); builder.alterActionList = this.getAlterActionList(); builder.isIfExists = this.getIsIfExists(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedAlterObjectStmt.Builder { private Builder() {} @Override @CanIgnoreReturnValue public Builder setHintList(List v) { super.setHintList(v); return this; } @Override @CanIgnoreReturnValue public Builder setNamePath(List v) { super.setNamePath(v); return this; } @Override @CanIgnoreReturnValue public Builder setAlterActionList(List v) { super.setAlterActionList(v); return this; } @Override @CanIgnoreReturnValue public Builder setIsIfExists(boolean v) { super.setIsIfExists(v); return this; } @Override public final ResolvedAlterConnectionStmt build() { validate(); return new ResolvedAlterConnectionStmt( hintList, namePath, alterActionList, isIfExists); } @Override protected void validate() { super.validate(); } } public static final ResolvedAlterConnectionStmt deserialize( ResolvedAlterConnectionStmtProto proto, AbstractDeserializationHelper helper) { return new ResolvedAlterConnectionStmt(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_ALTER_CONNECTION_STMT; } @Override public final String nodeKindString() { return "AlterConnectionStmt"; } /** * 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(); ResolvedAlterConnectionStmtProto.Builder childBuilder = ResolvedAlterConnectionStmtProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedAlterConnectionStmtNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedAlterConnectionStmtProto.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, ResolvedAlterConnectionStmtProto.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 public ResolvedAlterConnectionStmt accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); } } /** * ResolvedLockMode optionally indicates whether locks should be * acquired on the data accessed during a ResolvedTableScan. * *

`strength` specifies the strength of the locks to be acquired. */ public static final class ResolvedLockMode extends ResolvedArgument { private final LockStrengthType strength; ResolvedLockMode(ResolvedLockModeProto proto, AbstractDeserializationHelper helper) { super(proto.getParent(), helper); strength = proto.getStrength(); } ResolvedLockMode( LockStrengthType strength) { super(); this.strength = strength; } @Override public Builder toBuilder() { Builder builder = builder(); builder.strength = this.getStrength(); return builder; } public static Builder builder() { return new Builder(); } public static final class Builder extends ResolvedArgument.Builder { protected LockStrengthType strength = null; private Builder() {} @CanIgnoreReturnValue public Builder setStrength(LockStrengthType v) { this.strength = v; Preconditions.checkNotNull(v, "strength must not be null"); return this; } @Override public final ResolvedLockMode build() { validate(); return new ResolvedLockMode( strength); } @Override protected void validate() { super.validate(); Preconditions.checkArgument( strength != null, "strength must be set"); } } public static final ResolvedLockMode deserialize( ResolvedLockModeProto proto, AbstractDeserializationHelper helper) { return new ResolvedLockMode(proto, helper); } @Override public final ResolvedNodeKind nodeKind() { return ResolvedNodeKind.RESOLVED_LOCK_MODE; } @Override public final String nodeKindString() { return "LockMode"; } /** * 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(); ResolvedLockModeProto.Builder childBuilder = ResolvedLockModeProto.newBuilder(); serialize(fileDescriptorSetsBuilder, childBuilder); builder.setResolvedLockModeNode(childBuilder.build()); } /** * Serializes this node into the given {@link ResolvedLockModeProto.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, ResolvedLockModeProto.Builder proto) { proto.clear(); // Serialize superclass state to the parent field of the proto. ResolvedArgumentProto parent = (ResolvedArgumentProto) super.serialize(fileDescriptorSetsBuilder); proto.setParent(parent); // strength is a leaf type that can be set as a proto field directly. // (see scalar types in (broken link).py for more information.) proto.setStrength(this.getStrength()); } public final LockStrengthType getStrength() { return strength; } @Override public void accept(Visitor visitor) { visitor.visit(this); } @Override public ResolvedLockMode accept(RewritingVisitor visitor) { return visitor.visit(this); } @Override protected void acceptChildren(Visitor visitor) { super.acceptChildren(visitor); } public void collectDebugStringFields(List fields) { super.collectDebugStringFields(fields); { fields.add(new DebugStringField("strength", DebugStrings.toStringImpl(strength))); } } } }