Indhumathi27 opened a new pull request #3754: URL: https://github.com/apache/carbondata/pull/3754 ### Why is this PR needed? Added documentation for cdc and scd scenarios ### What changes were proposed in this PR? Added documentation for cdc and scd scenarios ### Does this PR introduce any user interface change? - No ### Is any new testcase added? - No ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
CarbonDataQA1 commented on pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#issuecomment-625350618 Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2971/ ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#issuecomment-625357707 Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1253/ ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
ajantha-bhat commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r421943365 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,118 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) + .whenMatched(<condition>) + .updateExpr(updateMap) + .insertExpr(insertMap_u) + .whenNotMatched(<condition>) + .insertExpr(insertMap) + .whenNotMatchedAndExistsOnlyOnTarget(<condition>) + .delete() + .insertHistoryTableExpr(insertMap_d, <table_name>) + .execute() +``` +**NOTE:** SQL syntax for merge is not yet supported. + +##### Example code sample to implement ccd scenario Review comment: Just give a link to `MergeTestCase.scala` and test case name No need have same thing here ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
ajantha-bhat commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r421944153 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,118 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) Review comment: Need to explain what each and every API does here and when to use it. Because these are added newly by carbon ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r421969903 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,118 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) Review comment: UPdated the PR ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r421970035 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,118 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) + .whenMatched(<condition>) + .updateExpr(updateMap) + .insertExpr(insertMap_u) + .whenNotMatched(<condition>) + .insertExpr(insertMap) + .whenNotMatchedAndExistsOnlyOnTarget(<condition>) + .delete() + .insertHistoryTableExpr(insertMap_d, <table_name>) + .execute() +``` +**NOTE:** SQL syntax for merge is not yet supported. + +##### Example code sample to implement ccd scenario Review comment: done ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
ajantha-bhat commented on pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#issuecomment-625662779 @jackylk , @ravipesala : please check if this much info is enough or anything else need to be added. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
ajantha-bhat commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r421996289 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,118 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) Review comment: Need to mention `insertHistoryTableExpr` action also ? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
ajantha-bhat commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r421996663 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,62 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) + .whenMatched(<condition>) + .updateExpr(updateMap) + .insertExpr(insertMap_u) + .whenNotMatched(<condition>) + .insertExpr(insertMap) + .whenNotMatchedAndExistsOnlyOnTarget(<condition>) + .delete() + .execute() +``` + +#### MERGE API Operation Semantics +Below is the detailed description of the `merge` API operation. +* `merge` will merge the datasets based on a condition. +* `whenMatched` clauses are executed when a source row matches a target table row based on the match condition. + These clauses have the following semantics. + * `whenMatched` clauses can have at most one updateExpr and one delete action. The `updateExpr` action in merge only updates the specified columns of the matched target row. The `delete` action deletes the matched row. + * If there are two `whenMatched` clauses, then they are evaluated in order they are specified. The first clause must have a clause condition (otherwise the second clause is never executed). + * If both `whenMatched` clauses have conditions and neither of the conditions are true for a matching source-target row pair, then the matched target row is left unchanged. +* `whenNotMatched` clause is executed when a source row does not match any target row based on the match condition. + * `whenNotMatched` clause can have only the `insertExpr` action. The new row is generated based on the specified column and corresponding expressions. Users do not need to specify all the columns in the target table. For unspecified target columns, NULL is inserted. +* `whenNotMatchedAndExistsOnlyOnTarget` clause is executed when row does not match source and exists only in target. This clause can have only delete action. + Review comment: what about other actions like `insertHistoryTableExpr` ? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r422006747 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,62 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) + .whenMatched(<condition>) + .updateExpr(updateMap) + .insertExpr(insertMap_u) + .whenNotMatched(<condition>) + .insertExpr(insertMap) + .whenNotMatchedAndExistsOnlyOnTarget(<condition>) + .delete() + .execute() +``` + +#### MERGE API Operation Semantics +Below is the detailed description of the `merge` API operation. +* `merge` will merge the datasets based on a condition. +* `whenMatched` clauses are executed when a source row matches a target table row based on the match condition. + These clauses have the following semantics. + * `whenMatched` clauses can have at most one updateExpr and one delete action. The `updateExpr` action in merge only updates the specified columns of the matched target row. The `delete` action deletes the matched row. + * If there are two `whenMatched` clauses, then they are evaluated in order they are specified. The first clause must have a clause condition (otherwise the second clause is never executed). + * If both `whenMatched` clauses have conditions and neither of the conditions are true for a matching source-target row pair, then the matched target row is left unchanged. +* `whenNotMatched` clause is executed when a source row does not match any target row based on the match condition. + * `whenNotMatched` clause can have only the `insertExpr` action. The new row is generated based on the specified column and corresponding expressions. Users do not need to specify all the columns in the target table. For unspecified target columns, NULL is inserted. +* `whenNotMatchedAndExistsOnlyOnTarget` clause is executed when row does not match source and exists only in target. This clause can have only delete action. + Review comment: its implementation not found in carbon ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r422006786 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,118 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) Review comment: its implementation not found in carbon ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#issuecomment-625707203 Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/1258/ ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
CarbonDataQA1 commented on pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#issuecomment-625713243 Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/2976/ ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
ravipesala commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r422154745 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,62 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) Review comment: Unless added SQL syntax it won't be so understandable to users. The only way to understand is through example. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
ravipesala commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r422156129 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,62 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) + .whenMatched(<condition>) + .updateExpr(updateMap) + .insertExpr(insertMap_u) + .whenNotMatched(<condition>) + .insertExpr(insertMap) + .whenNotMatchedAndExistsOnlyOnTarget(<condition>) + .delete() + .execute() +``` + +#### MERGE API Operation Semantics +Below is the detailed description of the `merge` API operation. +* `merge` will merge the datasets based on a condition. +* `whenMatched` clauses are executed when a source row matches a target table row based on the match condition. + These clauses have the following semantics. + * `whenMatched` clauses can have at most one updateExpr and one delete action. The `updateExpr` action in merge only updates the specified columns of the matched target row. The `delete` action deletes the matched row. + * If there are two `whenMatched` clauses, then they are evaluated in order they are specified. The first clause must have a clause condition (otherwise the second clause is never executed). + * If both `whenMatched` clauses have conditions and neither of the conditions are true for a matching source-target row pair, then the matched target row is left unchanged. +* `whenNotMatched` clause is executed when a source row does not match any target row based on the match condition. + * `whenNotMatched` clause can have only the `insertExpr` action. The new row is generated based on the specified column and corresponding expressions. Users do not need to specify all the columns in the target table. For unspecified target columns, NULL is inserted. +* `whenNotMatchedAndExistsOnlyOnTarget` clause is executed when row does not match source and exists only in target. This clause can have only delete action. + +**NOTE:** SQL syntax for merge is not yet supported. + +##### Example code to implement cdc/scd scenario + +Please refer example class [MergeTestCase](https://github.com/apache/carbondata/blob/master/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/merge/MergeTestCase.scala) to understand and implement scd and cdc scenarios. Review comment: I think we should create an example in the example module with the same test case content. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
ravipesala commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r422156325 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,62 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) + .whenMatched(<condition>) + .updateExpr(updateMap) + .insertExpr(insertMap_u) + .whenNotMatched(<condition>) + .insertExpr(insertMap) + .whenNotMatchedAndExistsOnlyOnTarget(<condition>) + .delete() + .execute() +``` + +#### MERGE API Operation Semantics +Below is the detailed description of the `merge` API operation. +* `merge` will merge the datasets based on a condition. +* `whenMatched` clauses are executed when a source row matches a target table row based on the match condition. + These clauses have the following semantics. + * `whenMatched` clauses can have at most one updateExpr and one delete action. The `updateExpr` action in merge only updates the specified columns of the matched target row. The `delete` action deletes the matched row. + * If there are two `whenMatched` clauses, then they are evaluated in order they are specified. The first clause must have a clause condition (otherwise the second clause is never executed). + * If both `whenMatched` clauses have conditions and neither of the conditions are true for a matching source-target row pair, then the matched target row is left unchanged. +* `whenNotMatched` clause is executed when a source row does not match any target row based on the match condition. + * `whenNotMatched` clause can have only the `insertExpr` action. The new row is generated based on the specified column and corresponding expressions. Users do not need to specify all the columns in the target table. For unspecified target columns, NULL is inserted. +* `whenNotMatchedAndExistsOnlyOnTarget` clause is executed when row does not match source and exists only in target. This clause can have only delete action. + +**NOTE:** SQL syntax for merge is not yet supported. + +##### Example code to implement cdc/scd scenario + +Please refer example class [MergeTestCase](https://github.com/apache/carbondata/blob/master/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/merge/MergeTestCase.scala) to understand and implement scd and cdc scenarios. Review comment: Can create a jira and add in next releases. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
Indhumathi27 commented on a change in pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#discussion_r422481823 ########## File path: docs/scd-and-cdc-guide.md ########## @@ -0,0 +1,62 @@ +<!-- + 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. +--> + +# Upsert into a Carbon DataSet using Merge + +## SCD and CDC Scenarios +Change Data Capture (CDC), is to apply all data changes generated from an external data set +into a target dataset. In other words, a set of changes (update/delete/insert) applied to an external +table needs to be applied to a target table. + +Slowly Changing Dimensions (SCD), are the dimensions in which the data changes slowly, rather +than changing regularly on a time basis. + +SCD and CDC data changes can be merged to a carbon dataset online using the data frame level `MERGE` API. + +#### MERGE API + +Below API merges the datasets online and applies the actions as per the conditions. + +``` + targetDS.merge(sourceDS, <condition>) + .whenMatched(<condition>) + .updateExpr(updateMap) + .insertExpr(insertMap_u) + .whenNotMatched(<condition>) + .insertExpr(insertMap) + .whenNotMatchedAndExistsOnlyOnTarget(<condition>) + .delete() + .execute() +``` + +#### MERGE API Operation Semantics +Below is the detailed description of the `merge` API operation. +* `merge` will merge the datasets based on a condition. +* `whenMatched` clauses are executed when a source row matches a target table row based on the match condition. + These clauses have the following semantics. + * `whenMatched` clauses can have at most one updateExpr and one delete action. The `updateExpr` action in merge only updates the specified columns of the matched target row. The `delete` action deletes the matched row. + * If there are two `whenMatched` clauses, then they are evaluated in order they are specified. The first clause must have a clause condition (otherwise the second clause is never executed). + * If both `whenMatched` clauses have conditions and neither of the conditions are true for a matching source-target row pair, then the matched target row is left unchanged. +* `whenNotMatched` clause is executed when a source row does not match any target row based on the match condition. + * `whenNotMatched` clause can have only the `insertExpr` action. The new row is generated based on the specified column and corresponding expressions. Users do not need to specify all the columns in the target table. For unspecified target columns, NULL is inserted. +* `whenNotMatchedAndExistsOnlyOnTarget` clause is executed when row does not match source and exists only in target. This clause can have only delete action. + +**NOTE:** SQL syntax for merge is not yet supported. + +##### Example code to implement cdc/scd scenario + +Please refer example class [MergeTestCase](https://github.com/apache/carbondata/blob/master/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/merge/MergeTestCase.scala) to understand and implement scd and cdc scenarios. Review comment: Created JIRA `CARBONDATA-3813` to add in next release. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
ajantha-bhat commented on pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#issuecomment-628404560 LGTM ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
In reply to this post by GitBox
kunal642 commented on pull request #3754: URL: https://github.com/apache/carbondata/pull/3754#issuecomment-629052507 LGTM ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [hidden email] |
Free forum by Nabble | Edit this page |