Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

added option for truncation in overwrite #509

Closed
wants to merge 1 commit into from
Closed

added option for truncation in overwrite #509

wants to merge 1 commit into from

Conversation

ai-bq
Copy link
Collaborator

@ai-bq ai-bq commented Oct 19, 2022

Summary

Some users require the option of truncating a table rather than dropping it in overwrite mode to retain table privileges.

Description

Truncate table was added to table utilities as well as the option of truncation through the dataframe writing options.

Related Issue

#507

Additional Reviewers

@alexey-temnikov
@jeremyp-bq
@jonathanl-bq
@alexr-bq

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Alex Impert seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov
Copy link

codecov bot commented Oct 19, 2022

Codecov Report

Merging #509 (7e1125d) into main (00d0c05) will decrease coverage by 0.15%.
The diff coverage is 63.63%.

@@            Coverage Diff             @@
##             main     #509      +/-   ##
==========================================
- Coverage   87.52%   87.37%   -0.16%     
==========================================
  Files          44       44              
  Lines        1988     1996       +8     
  Branches      110      124      +14     
==========================================
+ Hits         1740     1744       +4     
- Misses        248      252       +4     
Flag Coverage Δ
unittests 87.37% <63.63%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...n/scala/com/vertica/spark/config/WriteConfig.scala 100.00% <ø> (ø)
...cala/com/vertica/spark/util/table/TableUtils.scala 80.19% <0.00%> (-1.63%) ⬇️
.../vertica/spark/datasource/core/DSConfigSetup.scala 87.74% <66.66%> (-0.47%) ⬇️
...e/core/VerticaDistributedFilesystemWritePipe.scala 88.20% <100.00%> (+0.05%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jeremyprime
Copy link
Collaborator

@ai-bq you'll need to sign the CLA (you should have gotten an email) before that check will pass.

Also note there is a large file at examples/scala/cs that shouldn't be committed.

@@ -89,7 +89,8 @@ final case class DistributedFilesystemWriteConfig(jdbcConfig: JDBCConfig,
saveJobStatusTable: Boolean,
mergeKey: Option[ValidColumnList] = None,
timeOperations : Boolean = true,
arrayLength: Long = 0
arrayLength: Long = 0,
truncate: Boolean
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add this to the Javadoc above (and add the other missing params at the same time).

At some point, although not in this PR, we should consider just passing an options object rather than adding more and more parameters.

@@ -462,6 +462,17 @@ object DSConfigSetupUtils {
config.get("target_table_sql").validNec
}

def getTruncate(config: Map[String, String]): ValidationResult[Boolean] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to add a unit test for this in order to satisfy the coverage rules we have in place.

@@ -260,6 +265,11 @@ class TableUtils(schemaTools: SchemaToolsInterface, jdbcLayer: JdbcLayerInterfac
.left.map(err => err.context("JDBC Error dropping table"))
}

def truncateTable(tablename: TableName): ConnectorResult[Unit] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we can add a unit test for this as well, we should follow whatever unit testing was done for drop table.

@ai-bq ai-bq closed this Oct 20, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants