Skip to content

Commit

Permalink
change:1.更新hbase相关
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyofin committed Sep 4, 2019
1 parent 7ecbaa2 commit b0f4231
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
12 changes: 12 additions & 0 deletions spark-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,25 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-spark</artifactId>
<version>4.14.0-HBase-1.2</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-core</artifactId>
<version>4.14.0-HBase-1.2</version>
</dependency>

<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-client</artifactId>
<version>4.14.1-HBase-1.2</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.hadoop</groupId>-->
<!--<artifactId>hadoop-client</artifactId>-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package com.wugui.sparkstarter.hbase;

import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.*;

/**
* @program: bigdata-starter
* @author: huzekang
* @create: 2019-08-30 18:07
**/
public class SparkHbasePhoenix {
public static void main(String[] args) {
public static void main(String[] args) throws AnalysisException {
SparkSession sparkSession = SparkSession.builder().appName("SparkHBaseDataFrame").master("local").getOrCreate();

Dataset<Row> dataset = sparkSession.read()
.format("jdbc")
.option("driver", "org.apache.phoenix.jdbc.PhoenixDriver")
.option("phoenix.schema.isNamespaceMappingEnabled", "true")
.option("url", "jdbc:phoenix:cdh01:2181")
.option("dbtable", "userInfo")
.option("dbtable", "patient_test")
.load();
dataset.printSchema();
dataset.select("ID").show();
dataset.createTempView("abc");
sparkSession.sql("select empi,id from abc where id> 1005 ").show();
}
}
35 changes: 35 additions & 0 deletions spark-starter/src/main/resources/hbase-site.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<configuration>
<property>
<name>hbase.regionserver.wal.codec</name>
<value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value>
</property>
<property>
<name>phoenix.schema.isNamespaceMappingEnabled</name>
<value>true</value>
</property>
<property>
<name>phoenix.schema.mapSystemTablesToNamespace</name>
<value>true</value>
</property>
</configuration>

0 comments on commit b0f4231

Please sign in to comment.