用SQL查询JSON数据:Charlatan

jopen 9年前

Charlatan是一个各种格式列表或流记录的查询引擎。它默认支持CSV或JSON格式,但可以轻松扩展支付其它格式。它提供了一种类似SQL的语言来查询数据值。

查询语法

SELECT <fields> FROM <source> [ WHERE <value> ] [ STARTING AT <index> ]
  • <fields>is a list of comma-separated field names. Each field name must exist in the source. When reading CSV files, the field names are the column names, while when reading JSON they represent keys.
  • <source>is the filename from which the data is read. The API is agnostique on this and one can implement support for any source type.
  • <value>is a SQL-like value, which can be either a constant (e.g.WHERE 1), a field (e.g.WHERE archived) or any operation using comparison operators (=,!=,<,<=,>,>=,AND,OR) and optionally parentheses (e.g.WHERE (foo > 2) AND (bar = "yo")). The parser allows to use&&instead ofANDand||instead ofOR.
  • <index>can be used to skip the first N records.

Constant values include strings, integers, floats, booleans and thenullvalue.

示例    SELECT CountryName FROM sample/csv/population.csv WHERE Year = 2010 AND Value > 50000000 AND Value < 70000000  SELECT name, age FROM sample/json/people.jsons WHERE stats.walking > 30 AND stats.biking < 300

项目主页:http://www.open-open.com/lib/view/home/1438146433941