如何在Apache Drill中从文件中选择所有列名(例如: - csv或json或,parquet)

时间:2016-09-07 07:28:55

标签: apache-drill

我在嵌入式模式下使用Drill in Window 10,最新版本为1.8。

我有一个钻取查询,用于从sql server数据库表中选择所有列: -

SELECT DISTINCT info.COLUMN_NAME AS `NAME`, info.TABLE_SCHEMA AS `TABLESCHEMA`, info.TABLE_NAME AS `TABLENAME`, info.ORDINAL_POSITION AS `POSITION`, info.IS_NULLABLE AS `ISNULLABLE`, info.DATA_TYPE AS `DATATYPE`, tc.CONSTRAINT_TYPE AS `CONSTRAINTTYPE`, kcufk.TABLE_SCHEMA AS `REFRENCESCHEMA`, kcufk.TABLE_NAME AS `REFRENCETABLE`, kcufk.COLUMN_NAME AS `REFRENCECOLUMN` FROM DemoSQLServer.INFORMATION_SCHEMA.`COLUMNS` info LEFT OUTER JOIN DemoSQLServer.INFORMATION_SCHEMA.`KEY_COLUMN_USAGE` kcu ON kcu.COLUMN_NAME = info.COLUMN_NAME AND kcu.TABLE_NAME = info.TABLE_NAME LEFT OUTER JOIN DemoSQLServer.INFORMATION_SCHEMA.`TABLE_CONSTRAINTS` tc ON tc.CONSTRAINT_NAME = kcu.CONSTRAINT_NAME AND tc.TABLE_NAME = kcu.TABLE_NAME LEFT OUTER JOIN DemoSQLServer.INFORMATION_SCHEMA.`REFERENTIAL_CONSTRAINTS` rk ON rk.CONSTRAINT_NAME = tc.CONSTRAINT_NAME LEFT OUTER JOIN DemoSQLServer.INFORMATION_SCHEMA.`KEY_COLUMN_USAGE` kcufk ON kcufk.CONSTRAINT_NAME = rk.UNIQUE_CONSTRAINT_NAME WHERE info.TABLE_NAME = 'Attribute' AND info.TABLE_SCHEMA = 'dbo' ORDER BY info.ORDINAL_POSITION ASC;

此查询将返回属性表中的所有列。

我想从一些文件中选择列名(例如:-csv或,parquet或json等)。 是否可以使用Drill。?

1 个答案:

答案 0 :(得分:2)

您可以像表格一样选择文件列。

示例查询:

select N_NAME,N_REGIONKEY from dfs.`<drill-home>/sample-data/nation.parquet`;

P.S。 - 确保已启用dfs插件。