“无法从空字符串创建路径"使用 S3 路径在配置单元中出现“CREATE TABLE AS"错误 [英] 'Can not create a Path from an empty string' Error for 'CREATE TABLE AS' in hive using S3 path

查看:27
本文介绍了“无法从空字符串创建路径"使用 S3 路径在配置单元中出现“CREATE TABLE AS"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Glue 目录中创建一个表,其中包含来自使用 hive 在 EMR 中运行的 spark 的 s3 路径位置.我尝试了以下命令,但出现错误:

I am trying to create a table in Glue catalog with s3 path location from spark running in EMR using hive. I have tried the following commands, but getting the error:

pyspark.sql.utils.AnalysisException:u'java.lang.IllegalArgumentException:无法从空字符串;'

sparksession.sql("CREATE TABLE IF NOT EXISTS abc LOCATION 's3://my-bucket/test/' as (SELECT * from my_table)")

sparksession.sql("CREATE TABLE abcSTORED AS PARQUET LOCATION 's3://my-bucket/test/' AS select * from my_table")

sparksession.sql("CREATE TABLE abcas SELECT * from my_table USING PARQUET LOCATION 's3://my-bucket/test/'")

有人可以建议我缺少的参数吗?

Can someone please suggest the parameters that I am missing?

推荐答案

在没有指定位置的情况下创建数据库时发生的问题:

The issue happens when a database is created without specified location:

CREATE DATABASE db_name;

要解决此问题,请在创建数据库时指定位置:

To fix the issue, specify location when create database:

CREATE DATABASE db_name LOCATION 's3://my-bucket/db_path';

然后,创建一个表:

USE db_name;
CREATE TABLE IF NOT EXISTS abc LOCATION 's3://my-bucket/db_path/abc' as (SELECT * from my_table)

这篇关于“无法从空字符串创建路径"使用 S3 路径在配置单元中出现“CREATE TABLE AS"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆