我有两个 Redshift 表。我可以在它们之间的 JOIN 上执行 select * (连接是在 id 列上执行的):
SELECT * FROM
table1 t1
LEFT JOIN table2 t2
ON t1.id = t2.user_id
Run Code Online (Sandbox Code Playgroud)
但是,当我将此语句包装在 CREATE TABLE 子句中时,我得到以下信息:
error: Invalid characters: code: 8001 context: Only ASCII characters are allowed in fixed length strings. Invalid ASCII char: c3 a1 query: 5183418 location: funcs_string.cpp:1545
c3a1 似乎是一个非 ASCII 字符。根据Redshift 文档和论坛帖子,VARCHAR 最多可以处理 4 字节字符。所以我认为这可能是我选择的列没有正确投射的问题,所以我尝试了以下方法:
CREATE TABLE table3 AS
SELECT CAST(t1.id AS VARCHAR(255))
FROM table1 t1
LEFT JOIN table2 t2
ON t1.id …Run Code Online (Sandbox Code Playgroud)