我试图将RDBMS表从postgres加载到postgres的Hive表中。为此,我编写了以下代码行以提取数据:
val inputDF = spark.read.format("jdbc").option("url", connectionUrl).option("dbtable", s"(${query}) as inpData").option("user", devUserName).option("password", devPassword).option("partitionColumn","empID").
option("lowerBound", 14345745528L).option("upperBound", 1152921477111580662L).option("numPartitions",100).load()
火花提交:
SPARK_MAJOR_VERSION=2 spark-submit --conf spark.ui.port=4090 --driver-class-path /home/repuser/jars/postgresql-42.1.4.jar --jars /home/repuser/jars/postgresql-42.1.4.jar --num-executors 120 --executor-cores 15 --executor-memory 50G --driver-memory 30G --driver-cores 4 --class com.partition.source.datacount counter.11-0.1.jar --master=yarn --deploy-mode=cluster --keytab /home/repuser/repuser.keytab --principal repuser@DEV.COM --files /usr/hdp/current/spark2-client/conf/hive-site.xml,testconnection.properties --name Counter --conf spark.executor.extraClassPath=/home/repuser/jars/postgresql-42.1.4.jar
我尝试读取的表具有一列:orderID,这是一个主键,并且具有唯一值。值下限:orderID的最小值和上限:最大值与值:oprion(“ partitionColumn”,“ orderID”)中的列名称:orderID一起给出,代码运行良好,可以从GreenPlum中拾取所有数据并将相同的数据插入Hive。
但是有些表具有两列作为主键。例如,我有一个表userLocation
有两列:referenceID & headerID
作为主键。有没有一种方法可以在.option("partitionColumn", columnName)
中使用多个列名。
我知道选项partitionColumn
不必是主键列。
如果没有一个具有唯一值的列,那么谁能让我知道如何在读取表时对数据进行分区?