用SQL查詢JSON數據:Charlatan
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. </ul>
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
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!