Metastore-like capabilities for various filesystems
Slowing down. Last release over 3 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install fsqlfsql
The fsql package's goal is to simplify the task of getting data from any file system, local or remote, possibly divided into multiple partitions, into a single data frame.
The package has querying capabilities, thus the name stands for "file system query language".
Quick Start
The core is installed just via pip install fsql. Additional filesystem support or output representation is installed via pip install fsql[s3] or pip install fsql[dask].
For examples of usage (and sort-of documentation), we use selected test files accompanied with explanatory comments:
Use Cases & Features
The canonical usecase is that you have data on S3 stored e.g. as <table_name>/year=<yyyy>/month=<mm>/day=<dd>/<filename>.csv, and you want to fetch a part of it (e.g., a week from the last month, every Monday last year, ...) as a single Pandas or Dask DataFrame, via a short command -- without having to write the boto3 crawl, the bytes2csv, the csv2pandas, etc.
The crawl/query part is traditionally covered by metastores, such as Hive Metastore or Glue Data Catalog.
Why, then, would you use fsql?
- If you don't have the metastore set up, using
fsqlis faster and has no operation/maintenance costs. - If your processing engine (Pandas, Dask, ...) does not cooperate with the metastore out of the box, plugging it to
fsqlis simpler. - If the storage structure is not supported by the metastore -- e.g., usually the
<columnName>=<value>is required, yet we often encounter just<value>with the column name provided externally. - If the name of the file bears any information, e.g., it is the timestamp of the event the file represent, or some id of the data source -- metastores usually treat individual filenames as meaningless (for a good reason, as distributed engines such as Spark just use hashes), however, we treat them as regular column.
- If the condition for fetching data is not trivial (not available as SQL function -- e.g., you want to fetch only those files for which some column returns 1 when fed to an ML model), the implementation provided by
fsqlis more efficient than manually fetching all partitions from metastore and evaluating locally.