Package: graphique
GraphQLservice forarrowtables andparquetdata sets. The schema for a query API is derived automatically.Usage%envPARQUET_PATH=...uvicorngraphique.service:appOpenhttp://localhost:8000/to try out the API inGraphiQL. There is a test fixture at./tests/fixtures/zipcodes.parquet.%envPARQUET_PATH=...strawberryexport-schemagraphique.service:app.schemaoutputs the graphql schema for a parquet data set.ConfigurationGraphique usesStarlette's config: in environment variables or a.envfile. Config variables are used as input to aparquet dataset.PARQUET_PATH: path to the parquet directory or fileFEDERATED = '': field name to extend typeQuerywith a federatedTableDEBUG = False: run service in debug mode, which includes metricsCOLUMNS = None: list of names, or mapping of aliases, of columns to selectFILTERS = None: jsonfilterquery for which rows to read at startupFor more options create a customASGIapp. Call graphique'sGraphQLon an arrowDataset,Scanner, orTable. The GraphQLTabletype will be the root Query type.Supply a mapping of names to datasets for multiple roots, and to enable federation.importpyarrow.datasetasdsfromgraphiqueimportGraphQLapp=GraphQL(ds.dataset(...))# Table is root query typeapp=GraphQL.federated({<name>:ds.dataset(...),...},keys={...})# Tables on federated fieldsStart like any ASGI app.uvicorn <module>:appConfiguration options exist to provide a convenient no-code solution, but are subject to change in the future. Using a custom app is recommended for production usage.APItypesDataset: interface for an arrow dataset, scanner, or table.Table: implements theDatasetinterface. Adds typedrow,columns, andfilterfields from introspecting the schema.Column: interface for an arrow column (a.k.a. ChunkedArray). Each arrow data type has a corresponding column implementation: Boolean, Int, Long, Float, Decimal, Date, Datetime, Time, Duration, Base64, String, List, Struct. All columns have avaluesfield for their list of scalars. Additional fields vary by type.Row: scalar fields. Arrow tables are column-oriented, and graphique encourages that usage for performance. A singlerowfield is provided for convenience, but a field for a list of rows is not. Requesting parallel columns is far more efficient.selectionslice: contiguous selection of rowsfilter: select rows with simple predicatesscan: select rows and project columns with expressionsprojectioncolumns: provides a field for everyColumnin the schemacolumn: access a column of any type by namerow: provides a field for each scalar of a single rowapply: transform columns by applying a functionjoin: join tables by key columnsaggregationgroup: group by given columns, and aggregate the othersruns: partition on adjacent values in given columns, transforming the others into list columnstables: return a list of tables by splitting on the scalars in list columnsflatten: flatten list columns with repeated scalarsorderingsort: sort table by given columnsrank: select rows with smallest or largest valuesPerformanceGraphique relies on nativePyArrowroutines wherever possible. Otherwise it falls back to usingNumPyor custom optimizations.By default, datasets are read on-demand, with only the necessary rows and columns scanned. Although graphique is a running service,parquet is performantat reading a subset of data. Optionally specifyFILTERSin the jsonfilterformat to read a subset of rows at startup, trading-off memory for latency. An empty filter ({}) will read the whole table.SpecifyingCOLUMNSwill limit memory usage when reading at startup (FILTERS). There is little speed difference as unused columns are inherently ignored. Optional aliasing can also be used for camel casing.If index columns are detected in the schema metadata, then an initialfilterwill also attempt a binary search on tables.Installation%pipinstallgraphique[server]Dependenciespyarrowstrawberry-graphql[asgi,cli]uvicorn (or otherASGI server)Tests100% branch coverage.%pytest[--cov]