首页 > 解决方案 > 使用 hive 中的内部连接数据创建一个新表 - 我收到一个错误

问题描述

SELECT 
    stock_prices_uday.trading_date, stock_companies_uday.symbol,
    stock_companies_uday.company_name, stock_companies_uday.headquarter,
    stock_companies_uday.sector, stock_companies_uday.sub_industry,
    stock_prices_uday.open, stock_prices_uday.close, 
    stock_prices_uday.low, stock_prices_uday.high 
INTO 
    JOIN1_UDAY
FROM 
    STOCK_PRICES_UDAY 
INNER JOIN 
    STOCK_COMPANIES_UDAY ON stock_companies_uday.symbol = stock_prices_uday.symbol;

我收到一个错误:

编译语句时出错:失败:ParseException 行 4:1 无法识别表达式规范中“INTO”“JOIN1_UDAY”“FROM”附近的输入

标签: sqljoinhiveinner-joincreate-table

解决方案


Hive 不支持INTO。使用CREATE TABLE AS

CREATE TABLE JOIN1_UDAY as
    SELECT stock_prices_uday.trading_date, stock_companies_uday.symbol ,stock_companies_uday.company_name,
        stock_companies_uday.headquarter,stock_companies_uday.sector,stock_companies_uday.sub_industry,stock_prices_uday.open,
        stock_prices_uday.close,stock_prices_uday.low,stock_prices_uday.high 
        INTO JOIN1_UDAY
        FROM STOCK_PRICES_UDAY INNER JOIN 
             STOCK_COMPANIES_UDAY 
             ON stock_companies_uday.symbol = stock_prices_uday.symbol;

推荐阅读