public static IQsiTreeNode VisitUpsertStmt(Upsert_stmtContext context) { var node = ImpalaTree.CreateWithSpan <ImpalaDataInsertActionNode>(context); if (context.with is not null) { node.Directives.Value = TableVisitor.VisitWithClause(context.with); } if (context.hint is not null) { node.PlanHints = context.hint.GetInputText(); } node.ConflictBehavior = QsiDataConflictBehavior.Update; node.Target.Value = TableVisitor.VisitTableName(context.name); if (context.columns is not null) { node.Columns = IdentifierVisitor.VisitIdentList(context.columns) .Select(i => new QsiQualifiedIdentifier(i)) .ToArray(); } node.ValueTable.Value = TableVisitor.VisitQueryStmt(context.query); return(node); }
public static IQsiTreeNode VisitCreateViewStmt(Create_view_stmtContext context) { var node = ImpalaTree.CreateWithSpan <QsiViewDefinitionNode>(context); node.ConflictBehavior = context.HasRule <If_not_exists_valContext>() ? QsiDefinitionConflictBehavior.Ignore : QsiDefinitionConflictBehavior.None; node.Identifier = IdentifierVisitor.VisitTableName(context.table_name()); node.Columns.Value = context.TryGetRuleContext <View_column_defsContext>(out var viewColumnDefs) ? VisitViewColumnDefs(viewColumnDefs) : TreeHelper.CreateAllColumnsDeclaration(); node.Source.Value = TableVisitor.VisitQueryStmt(context.query_stmt()); return(node); }
public static IQsiTreeNode VisitUpdateStmt(Update_stmtContext context) { var node = ImpalaTree.CreateWithSpan <QsiDataUpdateActionNode>(context); var wildcard = new QsiAllColumnNode(); var targetTable = new QsiDerivedTableNode { Columns = { Value = new QsiColumnsDeclarationNode { Columns = { wildcard } } } }; if (context.from is not null) { if (context.target.children.Count != 1) { throw new QsiException(QsiError.SyntaxError, $"'{context.target.GetInputText()}' is not a valid table alias or reference."); } wildcard.Path = IdentifierVisitor.VisitDottedPath(context.target); targetTable.Source.Value = TableVisitor.VisitFromClause(context.from); } else { targetTable.Source.Value = TableVisitor.VisitDottedPath(context.target); } if (context.where is not null) { targetTable.Where.Value = ExpressionVisitor.VisitWhereClause(context.where); } node.Target.Value = targetTable; node.SetValues.AddRange(ExpressionVisitor.VisitUpdateSetExprList(context.values)); return(node); }
private static void VisitCreateTblAsSelectParams(ImpalaTableDefinitionNode node, Create_tbl_as_select_paramsContext context) { node.IsExternal = context.tblDef.external; node.ConflictBehavior = context.tblDef.ifNotExists ? QsiDefinitionConflictBehavior.Ignore : QsiDefinitionConflictBehavior.None; node.Identifier = IdentifierVisitor.VisitTableName(context.tblDef.table_name()); node.DataSource.Value = TableVisitor.VisitQueryStmt(context.query); if (context.options.children?.Count > 0) { var fragment = ImpalaTree.CreateWithSpan <QsiExpressionFragmentNode>(context.options); fragment.Text = context.options.GetInputText(); node.Options.Value = fragment; } if (context.TryGetRuleContext <Primary_keysContext>(out var primaryKeys)) { node.PrimaryKeyColumnNames = IdentifierVisitor.VisitIdentList(primaryKeys.ident_list()).ToArray(); } if (context.TryGetRuleContext <Partitioned_data_layoutContext>(out var partitionedDataLayout)) { var fragment = ImpalaTree.CreateWithSpan <QsiExpressionFragmentNode>(context.options); fragment.Text = partitionedDataLayout.GetInputText(); node.KuduPartitionParams.Value = fragment; } if (context.TryGetRuleContext <Iceberg_partition_spec_listContext>(out var icebergPartitionSpecList)) { var fragment = ImpalaTree.CreateWithSpan <QsiExpressionFragmentNode>(context.options); fragment.Text = icebergPartitionSpecList.GetInputText(); node.IcebergPartitionSpecs.Value = fragment; } if (context.TryGetRuleContext <Ident_listContext>(out var identList)) { node.PartitionColumnNames = IdentifierVisitor.VisitIdentList(identList).ToArray(); } }