You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/09/27 11:17:17 UTC

[GitHub] [incubator-doris] chovy-3012 opened a new pull request #6761: [Feature] support spark connector sink stream data to doris

chovy-3012 opened a new pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761


   ## Proposed changes
   1. support spark conncetor writing stream data to doris
   2. refactor dataframe sink code . writing params be configured  in class "org.apache.doris.spark.cfg.SparkSettings" instead of "org.apache.doris.spark.sql.DorisWriterOption" , and some other static constant
   
   ## Types of changes
   
   What types of changes does your code introduce to Doris?
   _Put an `x` in the boxes that apply_
   
   - [ ] Bugfix (non-breaking change which fixes an issue)
   - [x] New feature (non-breaking change which adds functionality)
   - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
   - [ ] Documentation Update (if none of the other choices apply)
   - [x] Code refactor (Modify the code structure, format the code, etc...)
   - [ ] Optimization. Including functional usability improvements and performance improvements.
   - [ ] Dependency. Such as changes related to third-party components.
   - [ ] Other.
   
   ## Checklist
   
   _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
   
   - [ ] I have created an issue on (Fix #ISSUE) and described the bug/feature there in detail
   - [x] Compiling and unit tests pass locally with my changes
   - [x] I have added tests that prove my fix is effective or that my feature works
   - [ ] If these changes need document changes, I have updated the document
   - [ ] Any dependent changes have been merged
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] hf200012 commented on a change in pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
hf200012 commented on a change in pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761#discussion_r717222131



##########
File path: extension/spark-doris-connector/src/main/java/org/apache/doris/spark/CachedDorisStreamLoadClient.java
##########
@@ -0,0 +1,48 @@
+package org.apache.doris.spark;

Review comment:
       add license

##########
File path: extension/spark-doris-connector/src/test/scala/org/apache/doris/spark/sql/TestStreamSinkDoris.scala
##########
@@ -0,0 +1,56 @@
+// 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.doris.spark.sql
+
+import org.apache.spark.sql.SparkSession
+
+object TestStreamSinkDoris {
+  val kafkaServers = ""
+  val kafkaTopics = ""
+
+  val dorisFeNodes = "your_doris_host_port"
+  val dorisUser = "root"
+  val dorisPwd = ""
+  val dorisTable = "test.test_tbl"
+
+  def main(args: Array[String]): Unit = {
+    val sparkSession = SparkSession.builder()
+      .master("local")
+      .getOrCreate()
+
+    val dataFrame = sparkSession.readStream
+      .option("kafka.bootstrap.servers", kafkaServers)
+      .option("startingOffsets", "latest")
+      .option("subscribe", kafkaTopics)
+      .format("kafka")
+      .option("failOnDataLoss", false)
+      .load()
+
+    dataFrame.selectExpr("CAST(timestamp AS STRING)", "CAST(partition as STRING)")
+      .writeStream
+      .format("doris")
+      .option("checkpointLocation", "/tmp/test")
+      .option("doris.table.identifier", dorisTable)
+      .option("doris.fenodes", dorisFeNodes)
+      .option("user", dorisUser)
+      .option("password", dorisPwd)
+      .start().awaitTermination()
+

Review comment:
       Delete extra blank lines

##########
File path: extension/spark-doris-connector/src/main/java/org/apache/doris/spark/CachedDorisStreamLoadClient.java
##########
@@ -0,0 +1,48 @@
+package org.apache.doris.spark;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.cache.RemovalListener;
+import com.google.common.cache.RemovalNotification;
+import org.apache.doris.spark.cfg.SparkSettings;
+import org.apache.doris.spark.exception.DorisException;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author wei.zhao

Review comment:
       remove author




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] hf200012 merged pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
hf200012 merged pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761#issuecomment-928954278






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] chovy-3012 commented on pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
chovy-3012 commented on pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761#issuecomment-928752890


   > Please provide instructions for use and update spark connector related documents at the same time
   
   hi, I added both batch/stream writing instructions in doc , pls review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761#issuecomment-928954278






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] hf200012 commented on a change in pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
hf200012 commented on a change in pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761#discussion_r717234846



##########
File path: extension/spark-doris-connector/src/main/java/org/apache/doris/spark/CachedDorisStreamLoadClient.java
##########
@@ -0,0 +1,48 @@
+package org.apache.doris.spark;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.cache.RemovalListener;
+import com.google.common.cache.RemovalNotification;
+import org.apache.doris.spark.cfg.SparkSettings;
+import org.apache.doris.spark.exception.DorisException;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author wei.zhao

Review comment:
       remove author




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] hf200012 merged pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
hf200012 merged pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] chovy-3012 commented on pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
chovy-3012 commented on pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761#issuecomment-928752890


   > Please provide instructions for use and update spark connector related documents at the same time
   
   hi, I added both batch/stream writing instructions in doc , pls review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] hf200012 commented on a change in pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
hf200012 commented on a change in pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761#discussion_r717222131



##########
File path: extension/spark-doris-connector/src/main/java/org/apache/doris/spark/CachedDorisStreamLoadClient.java
##########
@@ -0,0 +1,48 @@
+package org.apache.doris.spark;

Review comment:
       add license

##########
File path: extension/spark-doris-connector/src/test/scala/org/apache/doris/spark/sql/TestStreamSinkDoris.scala
##########
@@ -0,0 +1,56 @@
+// 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.doris.spark.sql
+
+import org.apache.spark.sql.SparkSession
+
+object TestStreamSinkDoris {
+  val kafkaServers = ""
+  val kafkaTopics = ""
+
+  val dorisFeNodes = "your_doris_host_port"
+  val dorisUser = "root"
+  val dorisPwd = ""
+  val dorisTable = "test.test_tbl"
+
+  def main(args: Array[String]): Unit = {
+    val sparkSession = SparkSession.builder()
+      .master("local")
+      .getOrCreate()
+
+    val dataFrame = sparkSession.readStream
+      .option("kafka.bootstrap.servers", kafkaServers)
+      .option("startingOffsets", "latest")
+      .option("subscribe", kafkaTopics)
+      .format("kafka")
+      .option("failOnDataLoss", false)
+      .load()
+
+    dataFrame.selectExpr("CAST(timestamp AS STRING)", "CAST(partition as STRING)")
+      .writeStream
+      .format("doris")
+      .option("checkpointLocation", "/tmp/test")
+      .option("doris.table.identifier", dorisTable)
+      .option("doris.fenodes", dorisFeNodes)
+      .option("user", dorisUser)
+      .option("password", dorisPwd)
+      .start().awaitTermination()
+

Review comment:
       Delete extra blank lines




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] github-actions[bot] commented on pull request #6761: [Feature] support spark connector sink stream data to doris

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #6761:
URL: https://github.com/apache/incubator-doris/pull/6761#issuecomment-929029227


   PR approved by at least one committer and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org