示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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();
            }
        }