UNPKG

@tableau/taco-toolkit

Version:
54 lines (53 loc) 2.41 kB
import { Database } from 'duckdb-async'; import { TempDataManager } from '../../../modules/temp-data-manager'; import { TacoFileParser } from './base-taco-file-parser'; import { ColumnHeader } from '../../../types/column-header'; import { DataRow } from '../../../../shared/types/data-row'; export type ParquetTacoParserType = typeof ParquetTacoParser; type ParsedDataRow = Record<string, string | null>; export declare class ParquetTacoParser extends TacoFileParser { private tempDataManager; private extractorId; private filename; private filepath; private columnHeaderMap; private headersFromFile; private db; constructor(tempDataManager: TempDataManager, extractorId: string, filename: string); /** * Set columns metadata info to the parser. When columnHeaders are set, getColumnHeaders will * respect the given info. Otherwise, all fields are assumed as string type. * * To prevent the method from being misused, this method can be called once, otherwise, * it throws an error. */ setColumnHeaders(columnHeaders: ColumnHeader[]): void; /** * Get ColumnHeaders for a Parquet file. * * By default, it returns all column header fields and all columns are typed as string. * If columns metadata is set by setColumnHeaders, it will filter the columns with the given columnHeaders, * while the column order from the file is still preserved. */ getColumnHeaders(): Promise<ColumnHeader[]>; getRowCount(): Promise<number>; /** * Get the set of data rows from the Parquet file with the specified limit and offset. */ getDataRows(limit: number, offset: number): Promise<{ data: DataRow[]; hasMoreRows: boolean; }>; getDb(): Promise<Database>; /** * Retrieves the column names from the first row of a parquet file located at the given file path. * * @param {Database} db - The duckdb database instance to execute the query against. * @param {string} filepath - The file path of the parquet file to read from. * * @returns {Promise<string[]>} - A Promise that resolves with an array of string column names, or an empty array if no column names were found. */ private getColumnNamesFromFile; } export declare function stringifyData(datarows: Record<string, unknown>[]): asserts datarows is ParsedDataRow[]; export {};