import * as arrow from 'apache-arrow';
import { DataType } from 'apache-arrow/type';
import { ProtoDatasetField } from '@kepler.gl/types';
import { DatabaseConnection } from '@kepler.gl/utils';
export declare const SUPPORTED_DUCKDB_DROP_EXTENSIONS: string[];
export type DuckDBColumnDesc = {
    name: string;
    type: string;
};
/**
 * Queries a DuckDB table for the schema description.
 * @param connection An active DuckDB connection.
 * @param tableName A name of DuckDB table to query.
 * @returns An array of column names and DuckDB types.
 */
export declare function getDuckDBColumnTypes(connection: DatabaseConnection, tableName: string): Promise<DuckDBColumnDesc[]>;
/**
 * Generates a mapping of column names to their corresponding DuckDB data types.
 * @param columns An array of column descriptions from DuckDB. Check getDuckDBColumnTypes.
 * @returns A record where keys are column names and values are their data types.
 */
export declare function getDuckDBColumnTypesMap(columns: DuckDBColumnDesc[]): Record<string, string>;
/**
 * Quotes a table name for safe SQL usage.
 * Always quotes to handle all edge cases (spaces, special characters, reserved words).
 * For fully qualified names (containing dots), preserves the existing structure.
 * @param tableName The table name to quote.
 * @returns The table name, properly quoted.
 */
export declare function quoteTableName(tableName: string): string;
/**
 * Constructs an SQL query to select all columns from a given table,
 * converting specified columns to Well-Known Binary (WKB) format using ST_AsWKB,
 * and casting BIGINT columns to DOUBLE if specified.
 * @param tableName The name of the table from which to select data.
 * @param columns An array of column descriptors, each with a type and name.
 * @param options Optional parameters to control the conversion behavior.
 * @returns The constructed SQL query.
 */
export declare function castDuckDBTypesForKepler(tableName: string, columns: DuckDBColumnDesc[], options?: {
    geometryToWKB: boolean;
    bigIntToDouble: boolean;
}): string;
/**
 * Sets the GeoArrow WKB extension metadata for columns of type GEOMETRY in an Arrow table.
 * @param table The Apache Arrow table whose schema fields will be modified.
 * @param columns An array of column descriptors from a DuckDB table.
 */
export declare function setGeoArrowWKBExtension(table: arrow.Table, columns: DuckDBColumnDesc[]): void;
/**
 * Creates an arrow table from an array of arrow vectors and fields.
 * @param columns An array of arrow vectors.
 * @param fields An array of fields per arrow vector.
 * @param arrowSchema Optional arrow table schema when available.
 * @returns An arrow table.
 */
export declare const restoreArrowTable: (columns: arrow.Vector[], fields: ProtoDatasetField[], arrowSchema?: arrow.Schema) => arrow.Table<any>;
/**
 * DuckDb throws when geoarrow extensions are present in metadata.
 * @param table An arrow table to clear from extensions.
 * @returns A map of removed per field geoarrow extensions.
 */
export declare const removeUnsupportedExtensions: (table: arrow.Table) => Record<string, string>;
/**
 * Restore removed metadata extensions after a call to removeUnsupportedExtensions.
 * @param table An arrow table to restore geoarrow extensions.
 * @param removedExtensions A map of per field geoarrow extensions to restore.
 */
export declare const restoreUnsupportedExtensions: (table: arrow.Table, removedExtensions: Record<string, string>) => void;
/** Checks whether the given Apache Arrow JS type is a Point data type */
export declare function isGeoArrowPoint(type: DataType): boolean;
/** Checks whether the given Apache Arrow JS type is a Point data type */
export declare function isGeoArrowLineString(type: DataType): boolean;
/** Checks whether the given Apache Arrow JS type is a Polygon data type */
export declare function isGeoArrowPolygon(type: DataType): boolean;
/** Checks whether the given Apache Arrow JS type is a Polygon data type */
export declare function isGeoArrowMultiPoint(type: DataType): boolean;
/** Checks whether the given Apache Arrow JS type is a Polygon data type */
export declare function isGeoArrowMultiLineString(type: DataType): boolean;
/** Checks whether the given Apache Arrow JS type is a Polygon data type */
export declare function isGeoArrowMultiPolygon(type: DataType): boolean;
/**
 * Checks if the given SQL query is a SELECT query by using the EXPLAIN command.
 * @param connection The DuckDB connection instance.
 * @param query The SQL query to check.
 * @returns Resolves to `true` if the query is a SELECT statement, otherwise `false`.
 */
export declare function checkIsSelectQuery(connection: DatabaseConnection, query: string): Promise<boolean>;
/**
 * Split a string with potentially multiple SQL queries (separated as usual by ';') into an array of queries.
 * This implementation:
 *  - Handles single and double quoted strings with proper escaping
 *  - Ignores semicolons in line comments (--) and block comments (slash asterisk)
 *  - Trims whitespace from queries
 *  - Handles SQL-style escaped quotes ('' inside strings)
 *  - Returns only non-empty queries
 * @param input A string with potentially multiple SQL queries.
 * @returns An array of queries.
 */
export declare function splitSqlStatements(input: string): string[];
/**
 * Removes SQL comments from a given SQL string.
 * @param sql The SQL query string from which comments should be removed.
 * @returns The cleaned SQL string without comments.
 */
export declare function removeSQLComments(sql: string): string;
/**
 * Drops a table if it exists in the DuckDB database.
 * @param connection The DuckDB connection instance.
 * @param tableName The name of the table to drop.
 * @returns A promise that resolves when the operation is complete.
 * @throws Logs an error if the table drop operation fails.
 */
export declare const dropTableIfExists: (connection: DatabaseConnection, tableName: string) => Promise<void>;
/**
 * Imports a file into DuckDB as a table, supporting multiple formats from SUPPORTED_DUCKDB_DROP_EXTENSIONS.
 * @param file The file to be imported.
 * @returns A promise that resolves when the file has been processed into a DuckDB table.
 */
export declare function tableFromFile(file: File | null): Promise<null | Error>;
/**
 * Sanitizes a file name to be a valid DuckDB table name.
 * @param fileName The input file name to be sanitized.
 * @returns A valid DuckDB table name.
 */
export declare function sanitizeDuckDBTableName(fileName: string): string;
