Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 如何将设置为hiveconf变量的字符串转换为可作为表名一部分使用的对象_Variables_Hive_Hiveql - Fatal编程技术网

Variables 如何将设置为hiveconf变量的字符串转换为可作为表名一部分使用的对象

Variables 如何将设置为hiveconf变量的字符串转换为可作为表名一部分使用的对象,variables,hive,hiveql,Variables,Hive,Hiveql,我正在寻找一种从hiveconf变量字符串中删除引号的方法,以便将其用作表名的一部分: 基本上,我有 set sub_name = "123"; select ${hiveconf:sub_name} from table_${hiveconf:sub_name}; 执行时,我需要它像这样工作: select "123" from table_123; 为此,我可以用如下方式运行: set variable = "123"; set table_subname = 123; select

我正在寻找一种从
hiveconf
变量字符串中删除引号的方法,以便将其用作表名的一部分:

基本上,我有

set sub_name = "123";

select ${hiveconf:sub_name} from table_${hiveconf:sub_name};
执行时,我需要它像这样工作:

select "123" from table_123;
为此,我可以用如下方式运行:

set variable = "123";
set table_subname = 123;

select ${hiveconf:variable} from table_${hiveconf:table_subname};
这样就可以作为

select "123" from table_123;

但是,有没有一种优雅的方法可以只使用一个变量,一次作为字符串,一次作为表名的一部分?

我知道我可以这样做:
set variable=123
然后
从表{hiveconf:variable}中选择“{hiveconf:variable}”
,但如何反过来呢?这是一个坏例子,因为
选择123
选择“123”
一样有效。我知道我可以这样做:
设置变量=123
然后
从表{hiveconf:variable}中选择“{hiveconf:variable}”,但是如何反过来呢?这是一个坏例子,因为
select 123
select“123”
一样有效,但是我想反过来。即
set sub_name=“abc”;从表${hiveconf:sub_name}中选择${hiveconf:sub_name}我将在表uu部分中执行某些操作以删除quotes@ira-(1)不会发生(2)它仍然比您建议的解决方案更干净,有2个变量您确定没有办法吗?或者你不知道怎么做?例如,在shell脚本中,这可以完成。我想直接在hql中这样做,尽管我确定。配置单元中的变量只不过是文本替换机制。你不能处理变量内容。是的,但我想反过来。即
set sub_name=“abc”;从表${hiveconf:sub_name}中选择${hiveconf:sub_name}我将在表uu部分中执行某些操作以删除quotes@ira-(1)不会发生(2)它仍然比您建议的解决方案更干净,有2个变量您确定没有办法吗?或者你不知道怎么做?例如,在shell脚本中,这可以完成。我想直接在hql中这样做,尽管我确定。配置单元中的变量只不过是文本替换机制。无法处理变量内容。
hive> create table table_abc as select 'X' as x;
OK
x
hive> set sub_name=abc;
hive> select "${hiveconf:sub_name}" from table_${hiveconf:sub_name};
OK
_c0
abc