提交 46a950df 编写于 作者: S shijinkui 提交者: Fabian Hueske

[FLINK-4562] [table] Move table examples into a dedicated module in flink-examples.

This closes #2460.
上级 83061ad0
......@@ -338,6 +338,7 @@ under the License.
<excludes>
<exclude>org.apache.flink:flink-examples-batch</exclude>
<exclude>org.apache.flink:flink-examples-streaming</exclude>
<exclude>org.apache.flink:flink-examples-table</exclude>
<exclude>org.apache.flink:flink-python</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
<exclude>log4j:log4j</exclude>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.flink</groupId>
<artifactId>flink-examples_2.10</artifactId>
<version>1.3-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<name>flink-examples-table</name>
<artifactId>flink-examples-table_2.10</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table_2.10</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>flink-table-examples_2.10</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadeTestJar>false</shadeTestJar>
<shadedArtifactAttached>false</shadedArtifactAttached>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>TableExamples</finalName>
<outputFile>flink-examples-table-with-dependencies.jar</outputFile>
<filters>
<filter>
<artifact>*:*</artifact>
<includes>
<include>org.codehaus.commons.compiler.properties</include>
<include>org/codehaus/janino/**</include>
<include>org/codehaus/commons/**</include>
<include>org/apache/calcite/**</include>
<include>org/apache/flink/table/**</include>
<include>org/apache/flink/shaded/calcite/com/google/common/**</include>
<include>org/apache/flink/shaded/calcite/org/eigenbase/util/property/**</include>
</includes>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
......@@ -17,11 +17,11 @@
*/
package org.apache.flink.table.examples.java;
import org.apache.flink.table.api.Table;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.table.api.java.BatchTableEnvironment;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.TableEnvironment;
import org.apache.flink.table.api.java.BatchTableEnvironment;
/**
* Simple example that shows how the Batch SQL API is used in Java.
......
......@@ -17,11 +17,11 @@
*/
package org.apache.flink.table.examples.java;
import org.apache.flink.table.api.Table;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.table.api.java.BatchTableEnvironment;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.TableEnvironment;
import org.apache.flink.table.api.java.BatchTableEnvironment;
/**
* Simple example for demonstrating the use of the Table API for a Word Count in Java.
......
......@@ -18,9 +18,9 @@
package org.apache.flink.table.examples.scala
import org.apache.flink.api.scala._
import org.apache.flink.table.api.scala._
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}
import org.apache.flink.table.api.TableEnvironment
import org.apache.flink.table.api.scala._
/**
* Simple example for demonstrating the use of SQL on a Stream Table.
......
......@@ -18,9 +18,9 @@
package org.apache.flink.table.examples.scala
import org.apache.flink.api.scala._
import org.apache.flink.table.api.scala._
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}
import org.apache.flink.table.api.TableEnvironment
import org.apache.flink.table.api.scala._
/**
* Simple example for demonstrating the use of Table API on a Stream Table.
......@@ -28,7 +28,6 @@ import org.apache.flink.table.api.TableEnvironment
* This example shows how to:
* - Convert DataStreams to Tables
* - Apply union, select, and filter operations
*
*/
object StreamTableExample {
......
......@@ -68,5 +68,6 @@ under the License.
<modules>
<module>flink-examples-batch</module>
<module>flink-examples-streaming</module>
<module>flink-examples-table</module>
</modules>
</project>
......@@ -25,7 +25,6 @@ import org.apache.flink.table.api.scala._
import org.apache.flink.api.scala.util.CollectionDataSets
import org.apache.flink.types.Row
import org.apache.flink.table.api.TableEnvironment
import org.apache.flink.table.examples.scala.WordCountTable.{WC => MyWC}
import org.apache.flink.test.util.TestBaseUtils
import org.junit._
import org.junit.runner.RunWith
......@@ -156,17 +155,17 @@ class AggregationsITCase(
val tEnv = TableEnvironment.getTableEnvironment(env, config)
val input = env.fromElements(
MyWC("hello", 1),
MyWC("hello", 1),
MyWC("ciao", 1),
MyWC("hola", 1),
MyWC("hola", 1))
WC("hello", 1),
WC("hello", 1),
WC("ciao", 1),
WC("hola", 1),
WC("hola", 1))
val expr = input.toTable(tEnv)
val result = expr
.groupBy('word)
.select('word, 'frequency.sum as 'frequency)
.filter('frequency === 2)
.toDataSet[MyWC]
.toDataSet[WC]
val mappedResult = result.map(w => (w.word, w.frequency * 10)).collect()
val expected = "(hello,20)\n" + "(hola,20)"
......@@ -339,4 +338,6 @@ class AggregationsITCase(
val results = t.toDataSet[Row].collect()
TestBaseUtils.compareResultAsText(results.asJava, expected)
}
case class WC(word: String, frequency: Long)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册