Snowflake ODBC 到 Excel,包含空格的字段名称错误
Snowflake ODBC to Excel, errors on field names containing spaces
我们有一组非常复杂的表,嵌套视图最终在 Tableau 服务器上提供了一系列仪表板。基本视图在某些数据字段上使用“as”子句来创建字段名称中带有空格的字段(i.e.somefieldname 作为“Some Field Name”)。以后的视图使用 * 通配符来检索所有值。 Tableau 能够处理它。
现在的问题是用户想要访问 Excel 中的那些最终视图。
我们在他们的工作站上建立了一个 ODBC 连接,当他们从最终视图之一中提取数据时。但是,字段名称中包含空白的字段显示为错误,并且在生成的工作表中为空白。我试图在该最终视图上构建一个视图并使用“as”子句删除字段名称中的空格,但一直无法为源字段找到正确的 SQL 语法。我试过括号,但没用。
我们试试 Power BI 会更好吗?我们的数据管理人员才刚刚开始使用它;还没看,明天就看
提前感谢您提供的任何提示!
娄
使用重命名的列在最终视图之上创建一个视图可能是最简单的解决方案。从用空格创建的列(更一般地说:用 "
围绕其字段 name/s 创建的列)的 selecting 的 SQL 语法是当您 select 时,将列放在双引号 ("
) 中。这是一个例子:
-- Create a sample table. The first column contains spaces and capitals
create or replace table test_table
(
"Column with Spaces" varchar, -- A column created with quotes around it means that you can put anything into the field name. Including spaces & funky characters
col_without_spaces varchar
);
-- Insert some sample data
insert overwrite into test_table
values ('row1 col1', 'row1 col2'),
('row2 col1', 'row2 col2');
-- Create a view that renames columns
create or replace view test_view as
(
select
"Column with Spaces" as col_1, -- But now you have to select it like this since the spaces and capital letters have been treated literally in the create table statement
col_without_spaces as col_2
from test_table
);
-- Select from the view
select * from test_view;
生产:
+---------+---------+
|COL_1 |COL2 |
+---------+---------+
|row1 col1|row1 col2|
|row2 col1|row2 col2|
+---------+---------+
我们有一组非常复杂的表,嵌套视图最终在 Tableau 服务器上提供了一系列仪表板。基本视图在某些数据字段上使用“as”子句来创建字段名称中带有空格的字段(i.e.somefieldname 作为“Some Field Name”)。以后的视图使用 * 通配符来检索所有值。 Tableau 能够处理它。
现在的问题是用户想要访问 Excel 中的那些最终视图。
我们在他们的工作站上建立了一个 ODBC 连接,当他们从最终视图之一中提取数据时。但是,字段名称中包含空白的字段显示为错误,并且在生成的工作表中为空白。我试图在该最终视图上构建一个视图并使用“as”子句删除字段名称中的空格,但一直无法为源字段找到正确的 SQL 语法。我试过括号,但没用。
我们试试 Power BI 会更好吗?我们的数据管理人员才刚刚开始使用它;还没看,明天就看
提前感谢您提供的任何提示! 娄
使用重命名的列在最终视图之上创建一个视图可能是最简单的解决方案。从用空格创建的列(更一般地说:用 "
围绕其字段 name/s 创建的列)的 selecting 的 SQL 语法是当您 select 时,将列放在双引号 ("
) 中。这是一个例子:
-- Create a sample table. The first column contains spaces and capitals
create or replace table test_table
(
"Column with Spaces" varchar, -- A column created with quotes around it means that you can put anything into the field name. Including spaces & funky characters
col_without_spaces varchar
);
-- Insert some sample data
insert overwrite into test_table
values ('row1 col1', 'row1 col2'),
('row2 col1', 'row2 col2');
-- Create a view that renames columns
create or replace view test_view as
(
select
"Column with Spaces" as col_1, -- But now you have to select it like this since the spaces and capital letters have been treated literally in the create table statement
col_without_spaces as col_2
from test_table
);
-- Select from the view
select * from test_view;
生产:
+---------+---------+
|COL_1 |COL2 |
+---------+---------+
|row1 col1|row1 col2|
|row2 col1|row2 col2|
+---------+---------+