【hudi】hudi表 常用字段类型SQL api测试

一、flink sql api

drop table my_db.hudi_type_flink;

CREATE TABLE my_db.hudi_type_flink(
	boolean_t boolean,
	tinyint_t tinyint,
	smallint_t smallint,
	integer_t integer,
	bigint_t bigint PRIMARY KEY NOT ENFORCED,
	float_t float,
	double_t double,
    decimal_t206 decimal(20,6),
	time_t time(3),
	date_t date,
	timestamp_t timestamp,
	string_t string,
	binary_t binary,
	array_t array<integer>,
	map_t map<string,string>
) WITH (
  'connector' = 'hudi',
  'path' = '/warehouse/my_db/hudi_type_flink',
  'table.type' = 'COPY_ON_WRITE'
);

insert into my_db.hudi_type_flink values(
true,
cast(8 as tinyint),
cast(8 as smallint),
8,
8,
8.8,
8.8,
88.88,
cast('18:01:01.666' as time),
cast('2020-01-01' as date),
current_timestamp,
'abc',
cast('abc' as binary),
array[1,2,3],
map['key','flink','value','connector1']
);

select * from my_db.hudi_type_flink;

二、spark sql api

drop table my_db.hudi_type_spark;

CREATE TABLE my_db.hudi_type_spark(
boolean_t boolean,
int_t int,
long_t long,
float_t float,
double_t double,
decimal_t206 decimal(20,6),
date_t date,
timestamp_t timestamp,
string_t string,
binary_t binary,
array_t array<int>,
map_t map<string,string>
) USING hudi
LOCATION '/warehouse/my_db/hudi_type_spark'
 TBLPROPERTIES (
  type = 'cow',
  primaryKey = 'long_t',
  'hoodie.datasource.hive_sync.support_timestamp' = 'true'
);

insert into my_db.hudi_type_spark values(
true
,8
,cast(8 as long)
,cast(8.8 as float)
,cast(8.8 as double)
,88.88
,current_date
,current_timestamp
,'abc'
,cast('abc' as binary)
,array(1,2,3)
,map('key','flink','value','conn1')
);

select * from my_db.hudi_type_spark;

你可能感兴趣的:(sql,数据库,hadoop)