hadoop - 配置单元SQL连接语句

标签 hadoop hive

我有一个查询

with ex as (
select z.num number, car.id as id, car.make as make, car.model, 'vehicles' as type from mytable mt LATERAL VIEW EXPLODE(mt.vehicles) vehiclestbl as honda
where car.working = true
union all
select z.num number, plane.id as id, plane.make as make, plane.model, 'flights' as type from mytable mt LATERAL VIEW EXPLODE(mt.flights) flightstbl as wings
where plane.active = true
union all
select z.num number, train.id as id, train.make as make, train.model, 'departures' as type from mytable mt LATERAL VIEW EXPLODE(mt.departures) departurestbl as wheels
where wheels.active = true
)

select ex0.*, 1499 as cost, model as location
from ex ex0
where mycolumn = 15

最终结果看起来像这样
number    id      make     model    type    cost      location
323       abc     make1    model1   type1   1499      modelLoc1
329       xyz     make2    model2   type2   1499      modelLoc2
984       lks     make3    model3   type3   1499      modelLoc3

我正在尝试将“数字”列与另一个外部表连接。每当我添加一个
INNER JOIN myothertable mot on mot.id = ex_id;

我收到“无法识别附近的输入”错误

最佳答案

在CTE中,该列称为number,因此我希望查询看起来像这样:

select ex0.*, 1499 as cost, model as location
from ex ex0 inner join
     myothertable mot
     on mot.id = ex0.number;
where mycolumn = 15;

关于hadoop - 配置单元SQL连接语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48406700/

相关文章:

hadoop - 查询未在配置单元中返回任何值

apache-spark - 在 Spark 的 saveAsTable 上

hadoop - 将可执行 jar 发送到 hadoop 集群并作为 "hadoop jar"运行

java - 不了解 MapReduce NPE

hadoop - 如何使用自定义Oozie EL函数读取HDFS文件

Hadoop:哪个映射器返回了哪个结果?

hadoop - 查询以查找最大值

hive - sqoop 从 hive 分区 parquet 表导出到 oracle

java - -DskipTests 和 -Dmaven.test.skip=true 有什么区别

java - 如何使用 TableMapReduceUtil 在 hbase 扫描器结果上运行 mapreduce