forked from apache/iceberg
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,726 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
String flinkVersion = '1.16.0' | ||
String flinkMajorVersion = '1.16' | ||
String scalaVersion = System.getProperty("scalaVersion") != null ? System.getProperty("scalaVersion") : System.getProperty("defaultScalaVersion") | ||
|
||
project(":iceberg-flink-example") { | ||
apply plugin: 'com.github.johnrengelman.shadow' | ||
|
||
tasks.jar.dependsOn tasks.shadowJar | ||
|
||
dependencies { | ||
implementation project(":iceberg-flink:iceberg-flink-runtime-${flinkMajorVersion}") | ||
implementation "org.apache.flink:flink-table-api-java:${flinkVersion}" | ||
implementation "org.apache.flink:flink-table-api-java-bridge:${flinkVersion}" | ||
implementation 'org.apache.flink:flink-runtime:1.16.0' | ||
implementation 'org.apache.flink:flink-table-runtime:1.16.0' | ||
// implementation 'org.apache.flink:flink-table-planner-loader:1.16.0' | ||
implementation "org.apache.flink:flink-sql-connector-hive-2.3.9_2.12:1.16.0" | ||
implementation 'org.apache.flink:flink-json:1.16.0' | ||
implementation "org.apache.flink:flink-connector-kafka:${flinkVersion}" | ||
implementation "org.apache.flink:flink-connector-base:${flinkVersion}" | ||
implementation "org.apache.flink:flink-connector-files:${flinkVersion}" | ||
implementation "org.apache.flink:flink-clients:1.16.0" | ||
implementation "org.apache.hadoop:hadoop-client" | ||
implementation 'org.apache.flink:flink-runtime-web:1.16.0' | ||
implementation 'org.apache.flink:flink-sql-gateway-api:1.16.0' | ||
implementation 'org.apache.flink:flink-table-planner_2.12:1.16.0' | ||
implementation 'org.apache.flink:flink-csv:1.16.0' | ||
} | ||
|
||
shadowJar { | ||
configurations = [project.configurations.runtimeClasspath] | ||
|
||
zip64 true | ||
|
||
// include the LICENSE and NOTICE files for the shaded Jar | ||
from(projectDir) { | ||
include 'LICENSE' | ||
include 'NOTICE' | ||
} | ||
|
||
// Relocate dependencies to avoid conflicts | ||
relocate 'org.apache.avro', 'org.apache.iceberg.shaded.org.apache.avro' | ||
relocate 'org.apache.parquet', 'org.apache.iceberg.shaded.org.apache.parquet' | ||
relocate 'com.google', 'org.apache.iceberg.shaded.com.google' | ||
relocate 'com.fasterxml', 'org.apache.iceberg.shaded.com.fasterxml' | ||
relocate 'com.github.benmanes', 'org.apache.iceberg.shaded.com.github.benmanes' | ||
relocate 'org.checkerframework', 'org.apache.iceberg.shaded.org.checkerframework' | ||
relocate 'shaded.parquet', 'org.apache.iceberg.shaded.org.apache.parquet.shaded' | ||
relocate 'org.apache.orc', 'org.apache.iceberg.shaded.org.apache.orc' | ||
relocate 'io.airlift', 'org.apache.iceberg.shaded.io.airlift' | ||
relocate 'org.threeten.extra', 'org.apache.iceberg.shaded.org.threeten.extra' | ||
relocate 'org.apache.httpcomponents.client5', 'org.apache.iceberg.shaded.org.apache.httpcomponents.client5' | ||
|
||
classifier null | ||
} | ||
|
||
jar { | ||
enabled = false | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
flink-example/src/main/java/org/apache/iceberg/flink/LogStoreExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package org.apache.iceberg.flink; | ||
|
||
import org.apache.flink.configuration.ConfigConstants; | ||
import org.apache.flink.configuration.Configuration; | ||
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; | ||
import org.apache.flink.table.api.Table; | ||
import org.apache.flink.table.api.TableEnvironment; | ||
import org.apache.flink.table.api.TableResult; | ||
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment; | ||
import org.apache.flink.types.Row; | ||
import org.apache.flink.util.CloseableIterator; | ||
|
||
public class LogStoreExample { | ||
|
||
private LogStoreExample() {} | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
Configuration configuration = new Configuration(); | ||
// configuration.setString("table.exec.iceberg.use-flip27-source", "true"); | ||
configuration.setString("execution.checkpointing.interval", "60s"); | ||
configuration.setString("state.checkpoint-storage", "jobmanager"); | ||
configuration.setBoolean(ConfigConstants.LOCAL_START_WEBSERVER, true); | ||
|
||
StreamExecutionEnvironment env = | ||
StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(configuration); | ||
TableEnvironment tEnv = StreamTableEnvironment.create(env); | ||
|
||
tEnv.executeSql( | ||
"CREATE CATALOG hive_catalog WITH (\n" | ||
+ " 'type'='iceberg',\n" | ||
+ " 'uri'='thrift://flink03:9083',\n" | ||
+ " 'warehouse'='hdfs://ns1/dtInsight/hive/warehouse'\n" | ||
+ ")"); | ||
|
||
tEnv.executeSql("USE CATALOG hive_catalog"); | ||
|
||
tEnv.executeSql("USE sec_index"); | ||
|
||
tEnv.executeSql("CREATE TABLE default_catalog.default_database.f (\n" + | ||
" id BIGINT,\n" + | ||
" name STRING\n" + | ||
") WITH (\n" + | ||
" 'connector' = 'filesystem',\n" + | ||
" 'path' = 'file:///Users/ada/tmp/log-store',\n" + | ||
" 'format' = 'csv'\n" + | ||
")"); | ||
|
||
// tEnv.executeSql("CREATE TABLE log_store_v2 (\n" + | ||
// " id BIGINT COMMENT 'unique id',\n" + | ||
// " name STRING\n" + | ||
// ") WITH (\n" + | ||
// " 'format-version' = '2',\n" + | ||
// " 'log-store' = 'kafka',\n" + | ||
// " 'kafka.bootstrap.servers' = '172.16.100.109:9092',\n" + | ||
// " 'kafka.topic' = 'log-store.v2'\n" + | ||
// ")"); | ||
|
||
// tEnv.executeSql("ALTER TABLE log_store_v1 SET ('log-store.kafka.bootstrap.servers'='172.16.100.109:9092')"); | ||
// tEnv.executeSql("ALTER TABLE log_store_v1 SET ('log-store.kafka.topic'='log-store.v2')"); | ||
|
||
// tEnv.executeSql("INSERT INTO log_store_v2 VALUES (3, 'bar')"); | ||
// tEnv.executeSql( | ||
// "SELECT * FROM log_store_v2 /*+ OPTIONS('streaming'='true', 'monitor-interval'='1s')*/") | ||
// .print(); | ||
|
||
tEnv.executeSql( | ||
"INSERT INTO default_catalog.default_database.f SELECT * FROM log_store_v2 /*+ OPTIONS('streaming'='true', 'monitor-interval'='1s', 'log-store'='none') */") | ||
; | ||
|
||
// tEnv.executeSql( | ||
// "INSERT INTO default_catalog.default_database.f VALUES(1, 'foo')"); | ||
// ; | ||
|
||
// tEnv.executeSql( | ||
// "SELECT * FROM log_store_v2 /*+ OPTIONS('log-store'='') */") | ||
// .print(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.