0

我试图了解整数分区表是如何工作的。然而,到目前为止,我无法创建一个。

这个查询有什么问题:

 #standardSQL
 CREATE or Replace TABLE temp.test_int_partition

 PARTITION BY RANGE_BUCKET(id, GENERATE_ARRAY(0,100))
 OPTIONS(
   description="test int partition"
 ) 
as 

WITH data as (
SELECT 12 as id, 'Alex' as name
UNION ALL 
SELECT 23 as id, 'Chimp' as name
)

SELECT *
from data

我收到此错误:

Error: PARTITION BY expression must be DATE(<timestamp_column>), a DATE column, or RANGE_BUCKET(<int64_column>, GENERATE_ARRAY(<int64_value>, <int64_value>, <int64_value>))

4

1 回答 1

0

问题是,尽管GENERATE_ARRAY被记录为GENERATE_ARRAY(start_expression, end_expression [, step_expression]),意味着step_expression是可选的,因为RANGE_BUCKET它是强制的。

所以以下将起作用:

 #standardSQL
 CREATE or Replace TABLE temp.test_int_partition

 PARTITION BY RANGE_BUCKET(id, GENERATE_ARRAY(0,100,1))
 OPTIONS(
   description="test int partition"
 ) 
as 

WITH data as (
SELECT 12 as id, 'Alex' as name
UNION ALL 
SELECT 23 as id, 'Chimp' as name
)

SELECT *
from data
于 2020-02-17T09:38:41.153 回答