import { ParserRuleContext } from 'antlr4ts/ParserRuleContext';
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
import { Range } from 'vscode-languageserver-textdocument';
import { ColumnReferenceContext, ComparisonContext, CreateTableContext, CreateViewContext, DefineValuesContext, DereferenceContext, ExistsContext, FromTableContext, FunctionCallContext, GroupByContext, HavingContext, InsertContext, JoinConditionContext, OrderByContext, PredicateContext, ProjectItemContext, QueryContext, QueryPrimaryContext, SelectClauseContext, SelectContext, StarContext, StatementContext, SubQueryContext, TableReferenceContext, UseContext, WhereContext, WithItemContext } from '../lib/FlinkSQLParser';
import { FlinkSQLParserVisitor } from '../lib/FlinkSQLParserVisitor';
import { EdgeIdentity, EdgeType, MetadataProviderFn, RelationPrimary, RelationType } from '../lineage.typing';
export declare const STAR_LABEL = "*";
export declare const COUNT_STAR_LABEL = "COUNT(*)";
export interface ColumnRef {
    tableId: string;
    columnId: string;
    isAssumed: boolean;
}
export declare class Column {
    readonly id: string;
    label: string;
    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?: Relation | undefined;
    readonly range?: Range | undefined;
    protected constructor(id: string, columns: Column[], parent?: Relation | undefined, range?: Range | undefined);
    abstract getNextColumnId(): string;
    findColumn(columnName: string): Column | undefined;
    resolveColumn(columnName: string): ColumnRef | undefined;
}
export declare class TableRelation extends Relation {
    readonly tablePrimary: RelationPrimary;
    constructor(id: string, tablePrimary: RelationPrimary, columns: Column[], parent?: QueryRelation, range?: Range);
    getNextColumnId(): string;
    addColumn(columnName: string, range: Range | undefined, isAssumed: boolean): {
        column: Column;
        ref: 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(name: string): Relation | undefined;
    findCTE(tableName: string): Relation | undefined;
    getCTENames(): string[];
    resolveRelationColumnWithTableName(columnName: string, range: Range, relation: Relation): ColumnRef | undefined;
    resolveRelationColumn(columnName: string, range: Range): ColumnRef | undefined;
}
export declare class InsertRelation extends Relation {
    readonly tablePrimary?: RelationPrimary | undefined;
    constructor(id: string, range?: Range, tablePrimary?: RelationPrimary | undefined);
    columnIdSeq: number;
    columnsSpecified: boolean;
    sinkTableRelation?: TableRelation | ViewRelation;
    getNextColumnId(): string;
}
export declare class ViewRelation extends Relation {
    readonly tablePrimary: RelationPrimary;
    constructor(id: string, tablePrimary: RelationPrimary, range?: Range);
    columnIdSeq: number;
    columnsSpecified: boolean;
    getNextColumnId(): string;
}
export declare abstract class FlinkSQLRelationVisitor<Result> extends AbstractParseTreeVisitor<Result> implements FlinkSQLParserVisitor<Result> {
    private getTable?;
    private relationInsertSeq;
    private relationViewSeq;
    private relationSeq;
    relationDDLColumns: Map<string, Column[]>;
    tableDDLs: Map<string, TableRelation>;
    viewDDLs: Map<string, ViewRelation>;
    catalogUsed?: string;
    databaseUsed?: string;
    lastQueryRelation: QueryRelation | undefined;
    protected currentInsertRelation?: InsertRelation;
    protected currentViewRelation?: ViewRelation;
    protected currentQueryRelation?: QueryRelation;
    abstract onRelation(_relation: TableRelation | ViewRelation | QueryRelation | InsertRelation, _alias?: string): void;
    abstract onColumnReference(_source: EdgeIdentity, _target: EdgeIdentity, _currentClause?: EdgeType): void;
    protected constructor(getTable?: MetadataProviderFn | undefined);
    getNextInsertRelationId(): string;
    getNextViewRelationId(): string;
    getNextRelationId(): string;
    private processClause;
    private reportTableReferences;
    private isStar;
    private handleSubQueryRelation;
    private addStarRelationColumn;
    private mapColumnToRelation;
    protected deriveColumnNameFromContext(ctx: ParserRuleContext): ExprColumn[];
    protected deriveColumnsFromDDL(ctx: DefineValuesContext): ExprColumn[];
    protected relationPrimaryFromMultipart(names: string[], type: RelationType): RelationPrimary;
    visitStatement(ctx: StatementContext): Result;
    visitUse(ctx: UseContext): Result;
    visitCreateTable(ctx: CreateTableContext): Result;
    visitCreateView(ctx: CreateViewContext): Result;
    visitInsert(ctx: InsertContext): Result;
    visitQuery(ctx: QueryContext): Result;
    visitQueryPrimary(ctx: QueryPrimaryContext): Result;
    visitSelect(ctx: SelectContext): Result;
    visitJoinCondition(ctx: JoinConditionContext): Result;
    visitTableReference(ctx: TableReferenceContext): Result;
    visitProjectItem(ctx: ProjectItemContext): Result;
    visitColumnReference(ctx: ColumnReferenceContext): Result;
    visitDereference(ctx: DereferenceContext): Result;
    visitFunctionCall(ctx: FunctionCallContext): Result;
    visitStar(ctx: StarContext): Result;
    visitComparison(ctx: ComparisonContext): Result;
    visitExists(ctx: ExistsContext): Result;
    visitPredicate(ctx: PredicateContext): Result;
    visitSubQuery(ctx: SubQueryContext): 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;
}
interface ExprColumn {
    tableName?: string;
    columnName: string;
    range?: Range;
}
export declare const RELATION_SEPARATOR = "__F__";
export declare function relationPrimaryToString(relationPrimary: RelationPrimary): string;
export {};
