Exemplo n.º 1
0
        public static IQsiTreeNode VisitUseStmt(Use_stmtContext context)
        {
            var node = ImpalaTree.CreateWithSpan <QsiChangeSearchPathActionNode>(context);

            node.Identifiers = new[] { IdentifierVisitor.VisitIdentOrDefault(context.ident_or_default()) };
            return(node);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        private static QsiColumnNode VisitViewColumnDef(View_column_defContext context)
        {
            var identOrDefault = context.ident_or_default();
            var node           = ImpalaTree.CreateWithSpan <QsiColumnReferenceNode>(identOrDefault);

            node.Name = new QsiQualifiedIdentifier(IdentifierVisitor.VisitIdentOrDefault(identOrDefault));
            return(node);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
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();
            }
        }