File

Description

You can query a file with a specified format directly with SQL.

Syntax

  1. file_format.`file_path`

Parameters

  • file_format

    Specifies a file format for a given file path, could be TEXTFILE, ORC, PARQUET, etc.

  • file_path

    Specifies a file path with a given format.

Examples

  1. -- PARQUET file
  2. SELECT * FROM parquet.`examples/src/main/resources/users.parquet`;
  3. +------+--------------+----------------+
  4. | name|favorite_color|favorite_numbers|
  5. +------+--------------+----------------+
  6. |Alyssa| null| [3, 9, 15, 20]|
  7. | Ben| red| []|
  8. +------+--------------+----------------+
  9. -- ORC file
  10. SELECT * FROM orc.`examples/src/main/resources/users.orc`;
  11. +------+--------------+----------------+
  12. | name|favorite_color|favorite_numbers|
  13. +------+--------------+----------------+
  14. |Alyssa| null| [3, 9, 15, 20]|
  15. | Ben| red| []|
  16. +------+--------------+----------------+
  17. -- JSON file
  18. SELECT * FROM json.`examples/src/main/resources/people.json`;
  19. +----+-------+
  20. | age| name|
  21. +----+-------+
  22. |null|Michael|
  23. | 30| Andy|
  24. | 19| Justin|
  25. +----+-------+