import { ParserRuleContext } from 'antlr4ts/ParserRuleContext';
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
import { Range } from 'vscode-languageserver-textdocument';
import { ColumnContext, ColumnReferenceContext, DereferenceContext, ExistsContext, ExprContext, FromTableContext, FunctionCallContext, GroupByContext, HavingContext, JoinConditionContext, NamedExpressionContext, OrderByContext, OrderItemContext, PredicateContext, QueryContext, QueryPrimaryContext, SelectClauseContext, SelectContext, SubQueryContext, TableReferenceContext, WhereContext, WithItemContext } from '../lib/FlinkSQLParser';
import { FlinkSQLParserVisitor } from '../lib/FlinkSQLParserVisitor';
import { EdgeType, TablePrimary } from '../lineage';
export declare const ROOT_QUERY_NAME = "[final result]";
export interface ColumnRef {
    tableId: string;
    columnId: string;
    isAssumed: boolean;
}
export declare class Column {
    readonly id: string;
    label: string;
    readonly range?: Range | undefined;
    readonly data?: unknown;
    readonly isAssumed?: boolean | undefined;
    readonly columnReferences: ColumnRef[];
    constructor(id: string, label: string, range?: Range | undefined, data?: unknown, isAssumed?: boolean | undefined);
}
export declare abstract class Relation {
    readonly id: string;
    readonly columns: Column[];
    readonly parent?: QueryRelation | undefined;
    readonly range?: Range | undefined;
    protected constructor(id: string, columns: Column[], parent?: QueryRelation | undefined, range?: Range | undefined);
    findColumn(columnName: string): Column | undefined;
    resolveColumn(columnName: string): ColumnRef | undefined;
}
export declare class TableRelation extends Relation {
    readonly tablePrimary: TablePrimary;
    readonly isFetched: boolean;
    readonly data?: unknown;
    constructor(id: string, tablePrimary: TablePrimary, columns: Column[], isFetched: boolean, parent?: QueryRelation, range?: Range, data?: unknown);
    addAssumedColumn(columnName: string, range: Range): ColumnRef;
}
export declare class QueryRelation extends Relation {
    ctes: Map<string, QueryRelation>;
    relations: Map<string, Relation>;
    columnIdSeq: number;
    currentClause?: EdgeType;
    currentColumnId?: string;
    columnReferences: ColumnRef[];
    constructor(id: string, parent?: QueryRelation, range?: Range);
    getNextColumnId(): string;
    findLocalRelation(tableName: string): Relation | undefined;
    findRelation(tableName: string): Relation | undefined;
    findCTE(tableName: string): Relation | undefined;
    getCTENames(): string[];
    resolveOrAssumeRelationColumn(columnName: string, range: Range, tableName?: string): ColumnRef | undefined;
}
export declare abstract class QueryStructureVisitor<Result> extends AbstractParseTreeVisitor<Result> implements FlinkSQLParserVisitor<Result> {
    getTable: (table: TablePrimary) => {
        table: {
            id: string;
            data: unknown;
        };
        columns: Array<{
            id: string;
            data: unknown;
        }>;
    } | undefined;
    readonly options?: {
        positionalRefsEnabled?: boolean | undefined;
    } | undefined;
    private relationSeq;
    lastRelation: QueryRelation | undefined;
    protected currentRelation: QueryRelation;
    protected constructor(getTable: (table: TablePrimary) => {
        table: {
            id: string;
            data: unknown;
        };
        columns: Array<{
            id: string;
            data: unknown;
        }>;
    } | undefined, options?: {
        positionalRefsEnabled?: boolean | undefined;
    } | undefined);
    abstract onRelation(_relation: TableRelation | QueryRelation, _alias?: string): void;
    abstract onColumnReference(_tableId: string, _columnId?: string): void;
    getNextRelationId(): string;
    rangeFromContext(ctx: ParserRuleContext): Range;
    protected extractTableAndColumn(ctx: ColumnContext): {
        tableName?: string;
        columnName: string;
    } | undefined;
    private asPrimaryExpression;
    protected deriveColumnName(ctx: ExprContext): string | undefined;
    private reportTableReferences;
    private isStar;
    private processStar;
    private addRelationColumns;
    private processClause;
    visitQuery(ctx: QueryContext): Result;
    visitQueryPrimary(ctx: QueryPrimaryContext): Result;
    visitSelect(ctx: SelectContext): Result;
    visitJoinCondition(ctx: JoinConditionContext): Result;
    visitTableReference(ctx: TableReferenceContext): Result;
    visitWithItem(ctx: WithItemContext): Result;
    visitSelectClause(ctx: SelectClauseContext): Result;
    visitFromTable(ctx: FromTableContext): Result;
    visitWhere(ctx: WhereContext): Result;
    visitGroupBy(ctx: GroupByContext): Result;
    visitHaving(ctx: HavingContext): Result;
    visitOrderBy(ctx: OrderByContext): Result;
    visitExists(ctx: ExistsContext): Result;
    visitPredicate(ctx: PredicateContext): Result;
    visitNamedExpression(ctx: NamedExpressionContext): Result;
    visitSubQuery(ctx: SubQueryContext): Result;
    visitFunctionCall(ctx: FunctionCallContext): Result;
    visitOrderItem(ctx: OrderItemContext): Result;
    private processColumnReference;
    visitColumnReference(ctx: ColumnReferenceContext): Result;
    visitDereference(ctx: DereferenceContext): Result;
}
export declare function tablePrimaryFromMultipart(names: string[]): TablePrimary;
