我有一个pyspark从TSV文件加载数据并将其保存为镶木地板文件,并将其保存为持久SQL表.
当我通过pyspark CLI逐行运行它时,它的工作方式与预期的完全相同.当我像使用spark-submit的应用程序一样运行时,它运行没有任何错误,但我得到奇怪的结果:1.数据被覆盖而不是附加.2.当我对它运行SQL查询时,即使镶木地板文件的大小为几千兆字节(我所期望的),我也没有返回任何数据.有什么建议?
码:
from pyspark import SparkContext, SparkConf
from pyspark.sql.types import *
from pyspark.sql.functions import *
csv_file = '/srv/spark/data/input/ipfixminute2018-03-28.tsv'
parquet_dir = '/srv/spark/data/parquet/ipfixminute'
sc = SparkContext(appName='import-ipfixminute')
spark = SQLContext(sc)
fields = [StructField('time_stamp', TimestampType(), True),
StructField('subscriberId', StringType(), True),
StructField('sourceIPv4Address', StringType(), True),
StructField('destinationIPv4Address', StringType(), True),
StructField('service',StringType(), True),
StructField('baseService',StringType(), True),
StructField('serverHostname', StringType(), True),
StructField('rat', StringType(), True),
StructField('userAgent', StringType(), True),
StructField('accessPoint', StringType(), True),
StructField('station', StringType(), True),
StructField('device', StringType(), True),
StructField('contentCategories', StringType(), True),
StructField('incomingOctets', LongType(), True),
StructField('outgoingOctets', LongType(), True),
StructField('incomingShapingDrops', IntegerType(), True),
StructField('outgoingShapingDrops', IntegerType(), True), …Run Code Online (Sandbox Code Playgroud) 我是Hadoop和Hive世界的新手.
我有一个奇怪的问题.当我在hive提示时工作.我创建了几个表,hive显示了这些表.
退出Hive会话后,我再次启动Hive终端"show tables;" 没有显示任何表格!我可以在HDFS中的'/ user/hive/warehouse'中看到表格.
我做错了什么.你能帮帮我吗?
我正在尝试在访问 Hive 表的 Cloud 4.2 Enterprise 上的 BigInsights 上运行 pyspark 脚本。
首先我创建 hive 表:
[biadmin@bi4c-xxxxx-mastermanager ~]$ hive
hive> CREATE TABLE pokes (foo INT, bar STRING);
OK
Time taken: 2.147 seconds
hive> LOAD DATA LOCAL INPATH '/usr/iop/4.2.0.0/hive/doc/examples/files/kv1.txt' OVERWRITE INTO TABLE pokes;
Loading data to table default.pokes
Table default.pokes stats: [numFiles=1, numRows=0, totalSize=5812, rawDataSize=0]
OK
Time taken: 0.49 seconds
hive>
Run Code Online (Sandbox Code Playgroud)
然后我创建了一个简单的 pyspark 脚本:
[biadmin@bi4c-xxxxxx-mastermanager ~]$ cat test_pokes.py
from pyspark import SparkContext
sc = SparkContext()
from pyspark.sql import HiveContext
hc = HiveContext(sc)
pokesRdd …Run Code Online (Sandbox Code Playgroud)