I've been reading the bigquery documentation since late last night and understand very little of it. It talks about loading data via different methods, but doesn't say how to create the table that I'm going to load data into. When I use the web UI it expects me to type out the schema. My table has over 400 columns. I will not type out hundreds of column names, types and lengths.
I've been uploading hundreds of GB of data in csv format to a google bucket. The csv files do not have column names. I have the schema in sql format which I prefer to use.
If I try creating a table through a query I get an error already on line 2 that says,
"Error: Encountered "" at line 2, column 1."
CREATE TABLE [example-mdi:myData_1.ST] (
`ADDRESS_ID` varchar(9),
`INDIVIDUAL_ID` varchar(2),
`FIRST_NAME` varchar(25),
`LAST_NAME` varchar(2),...
How can I do this or what is the right way?
答案 0 :(得分:3)
您可以使用CREATE TABLE
语句使用标准SQL创建表。在您的情况下,语句看起来像这样:
CREATE TABLE `example-mdi.myData_1.ST` (
`ADDRESS_ID` STRING,
`INDIVIDUAL_ID` STRING,
`FIRST_NAME` STRING,
`LAST_NAME` STRING,
...
);
答案 1 :(得分:2)
在Web UI中创建表格时 - 您可以按字段(Edit as Text
模式 - 默认模式)输入架构,也可以输入架构作为文本(CREATE TABLE
模式)
因此,如果您已经拥有sql格式的架构,则可以使用它(您可能需要稍微调整它以符合BigQuery)
查看有关不同客户的https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html的更多信息(在上面的“我们”部分中没有提供选项,因此我认为这就是您错过的原因)
P.S。截至今天,BigQuery不支持DDL - 因此db.deleteNote(position);
不可用
更新
截至今天 - 2018年1月17日 - BigQuery creating tables支持现在位于data definition language
答案 2 :(得分:1)
自 2021 年 4 月起,可以使用标准 SQL 直接完全创建复杂表(请参阅具体的 syntax guide)。
CREATE TABLE IF NOT EXISTS `project.dataset.table_name`
(
someName STRING
, dateTime TIMESTAMP NOT NULL -- REQUIRED or non-null column
, index INT64 -- INT64 for INTEGER column
, longitude FLOAT64 -- FLOAT64 for FLOAT column
, arr ARRAY< -- declaring Array. This ARRAY is of datatype STRUCT
STRUCT< -- declaring STRUCT
a FLOAT64 -- the individual STRUCT members do not need the STRUCT column name again
, b STRING
>
>
);
答案 3 :(得分:0)