Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

#1894 HadoopFsPersistenceFactory - adding Spline S3 write support #1912

Merged

Conversation

dk1844
Copy link
Contributor

@dk1844 dk1844 commented Sep 10, 2021

Problem summary

Vanilla spline 0.3.9 is not able to write the _LINEAGE file to an S3 location: #1896

Solution

Naively, S3 support was sketched into Spline 0.3.x, however, that was undesirable for multiple reasons. Instead, @wajda suggested overriding the default configuration of Spline

spline.persistence.composition.factories=za.co.absa.spline.persistence.mongo.MongoPersistenceFactory,za.co.absa.spline.persistence.hdfs.HdfsPersistenceFactory

to use a custom PersistenceFactory instead (look at the end):

spline.persistence.composition.factories=za.co.absa.spline.persistence.mongo.MongoPersistenceFactory,za.co.absa.enceladus.spline.persistence.HadoopFsPersistenceFactory

Using this approach, such a factory can be packed with Enceladus instead of Spline and the original Spline 0.3.9 can remain untouched. Thanks, @wajda!

Test run

Having provided all necessary requirements (Menas with a dataset's conformed publish path being located on S3, data, and configs), the test-run's result indeed includes the _LINEAGE file being present in the S3-located output:

$ aws --profile saml s3 ls s3://<my-bucket-name-here>/publish/superhero/ --recursive
2021-09-10 08:17:30       4048 publish/superhero/enceladus_info_date=2020-08-06/enceladus_info_version=1/_INFO
2021-09-10 08:17:28      10600 publish/superhero/enceladus_info_date=2020-08-06/enceladus_info_version=1/_LINEAGE
2021-09-10 08:17:28          0 publish/superhero/enceladus_info_date=2020-08-06/enceladus_info_version=1/_SUCCESS
2021-09-10 08:17:28      46426 publish/superhero/enceladus_info_date=2020-08-06/enceladus_info_version=1/part-00000-398b99ca-ee85-4c48-bc75-7120307f73a2-c000.snappy.pa
rquet

Release note suggestion

Enceladus can write Spline's _LINEAGE file in an S3 location.

Copy link
Contributor

@AdrianOlosutean AdrianOlosutean left a comment

Choose a reason for hiding this comment

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

Code reviewed

@@ -0,0 +1,98 @@
/*
* Copyright 2017 ABSA Group Limited
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this pass the check? Don't we have a rule to say it should be 2018?

Also in JSONSerialization.scala
And has a range HadoopFsPersistenceFactory.scala

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the apache-rat-plugin matchers don't include year (kind of logically), and it's not possible to specify. 🤔
On the other hand I remember Atum failing on wrong year, but it's not using the plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for noticing, it must have been as I copied some of the files from spline prior to making changes to them. Fixed.

I think the licence check only checks if there is a "valid" licence, but for the ABSA one, it does not check the year.

Copy link

@wajda wajda Sep 13, 2021

Choose a reason for hiding this comment

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

Don't we have a rule to say it should be 2018?

@Zejnilovic what is that rule and why?

@benedeki benedeki added the PR:reviewing Only for PR - PR is being reviewed by somebody; blocks merging label Sep 13, 2021
@@ -0,0 +1,98 @@
/*
* Copyright 2017 ABSA Group Limited
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the apache-rat-plugin matchers don't include year (kind of logically), and it's not possible to specify. 🤔
On the other hand I remember Atum failing on wrong year, but it's not using the plugin

override def store(lineage: DataLineage)(implicit ec: ExecutionContext): Future[Unit] = Future {
val pathOption = getPath(lineage)
import JSONSerialization._
for (path <- pathOption) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ha, interesting construction, a map replacement

Copy link

Choose a reason for hiding this comment

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

foreach replacement to be precise.


private def getPath(lineage: DataLineage): Option[Path] =
lineage.rootOperation match {
case dn: Write => Some(new Path(dn.path, fileName))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could the dn have a more explanatory name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, adjusted.

* @return FS + relative path
**/
def pathStringToFsWithPath(pathString: String): (FileSystem, Path) = {
pathString.toS3Location match {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This implicit function comes from Atum. That seems like a weird dependency. Wasn't it part of commons too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At this point of develop (using Atum 3.3.0, it is still part of Atum). Later, in Atum 3.5+, this is moved to commons.

Since this PR does not update Atum, the import change will have to be resolved in the future.

@benedeki benedeki removed the PR:reviewing Only for PR - PR is being reviewed by somebody; blocks merging label Sep 13, 2021
@benedeki
Copy link
Collaborator

Btw, shouldn't the new factory class be added to spline.properties configuration?

…oopFsPersistenceFactory` added to the spline.properties.template
@dk1844
Copy link
Contributor Author

dk1844 commented Sep 14, 2021

Btw, shouldn't the new factory class be added to spline.properties configuration?

Yes, it must be changed in the properties in order to be used, as I note in the PR description. However, spline.properties is not part of the repo, so I have reflected the change in the spline.properties.template instead. Good idea leading me to provide this as a default/template. 👍

* * [[za.co.absa.spline.persistence.hdfs.HdfsPersistenceFactory]].
*/
object HadoopFsPersistenceFactory {
private val fileNameKey = "spline.hdfs.file.name"
Copy link

@wajda wajda Sep 14, 2021

Choose a reason for hiding this comment

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

I think this was copied from the old Spline, and I'm not sure what naming convention for constants are set in Enceladus, but I remember there was a conversation on CQC some time ago - constant names should generally be written upper camel case - https://docs.scala-lang.org/style/naming-conventions.html#constants-values-and-variables

Copy link
Collaborator

Choose a reason for hiding this comment

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

Usually we adhere to capital letters too. But not very pedantic in code reviews about it. 😉

Copy link
Contributor

@AdrianOlosutean AdrianOlosutean left a comment

Choose a reason for hiding this comment

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

Code review

Copy link
Collaborator

@benedeki benedeki left a comment

Choose a reason for hiding this comment

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

  • code reviewed
  • pulled
  • built
  • run
    Ran it locally, want to run on AWS too, to verify S3 functionality

* Licensed 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
*
Copy link
Collaborator

Choose a reason for hiding this comment

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

For some reason, this empty line makes Scalastyle prevent my build.

@benedeki benedeki added the PR:tested Only for PR - PR was tested by a tester (person) label Sep 17, 2021
@benedeki
Copy link
Collaborator

✔️ Tested both locally and in AWS. The _LINEAGE file was created both on hfds and S3.
The PR change request is not in the code area, fix won't affect the test.

…ladus/spline/persistence/HadoopFsDataLineageWriter.scala

Co-authored-by: David Benedeki <14905969+benedeki@users.noreply.github.com>
@sonarcloud
Copy link

sonarcloud bot commented Sep 17, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dk1844 dk1844 merged commit 92d15d4 into develop Sep 17, 2021
@dk1844 dk1844 deleted the feature/1894-s3-support-for-spline0.3-persistence-factory branch September 17, 2021 19:35
dk1844 added a commit that referenced this pull request Nov 4, 2021
* Update for next development version 2.24.0-SNAPSHOT

* Suppress download noise in license check

* Suppress compiler warning of obsolete Java (#1892)

* 1868 statistics with missing counts and datasets missing proprties (#1873)

* 1868 statistics with missing counts and datasets missing proprties

* 1843 Summary page for properties (#1880)

* 1843 Home page with properties,  side panel with missing counts and summary page for properties with tab containing datasets missing that particular property

* Feature/1603 mapping table filtering general (#1879)

* #1603 serde tests for CR and MT DataFrameFilters
(mongo-bson-based serde tests for CR and MT DataFrameFilters, mongo-bson-based serde tests extended for CR with a blank mappingTableFilter)

* #1909 Increase the limit of columns shown in menas column selection

* 1903 Add validation for complex default values in mapping tables on import

* Project config and management updates (#1908)

Project config and management updates
* poc issue template
* CODEOWNERS update
* developers update
* Badges to README.md

* 1881 HyperConformance enceladus_info_version from payload  (#1896)

1881 HyperConformance enceladus_info_version from payload

* #1887 defaultTimestampTimeZone can be source type specific (#1899)

#1887 defaultTimestampTimeZone can be source type specific
* `DefaultsByFormat` extends the `Defaults` trait, being able to read defaults from configuration files
* `DefaultsByFormat` offers further granularity by first checking the format specific setting only then taking the global one
* Basic `GlobalDefaults` are not configuration dependent anymore
* Standardization now user `DefaultsByFormat` for its defaults, where rawFormat is used for format parameter
* Switched to configuration path to be `enceladus.defaultTimestampTimeZone.default` and `enceladus.defaultTimestampTimeZone.[rawFormat]` respectively
* `defaultTimestampTimeZone` is still supported/read as an obsolete fallback
Co-authored-by: Daniel K <dk1844@gmail.com>

* #1887 defaultTimestampTimeZone can be source type specific (#1916)

#1887 defaultTimestampTimeZone can be source type specific
* rename of the configuration prefix from `enceladus.` to `standardization.`

* #172 Save original timezone information in metadata file (#1900)

* Upgrade of Atum to 3.6.0
* Writing the default time zones for timestamps and dates into _INFO file

* #1894 `HadoopFsPersistenceFactory` - adding Spline S3 write support (#1912)

* #1894 Spline S3 support via custom persistence factory `HadoopFsPersistenceFactory`.
Co-authored-by: David Benedeki <14905969+benedeki@users.noreply.github.com>

* Update versions for release v2.24.0

* Update for next development version 2.25.0-SNAPSHOT

* #1926 Add executor extra java opts to helper scripts

* #1931 Add switch for running kinit in helper scripts

* #1882 Update Cobrix dependency to v.2.3.0

* #1882 Remove explicit "collapse_root" since it is the default since Cobrix 2.3.0

* #1882 Update Cobrix to 2.4.1 and update Cobol test suite for ASCII files.

* #1882 Bump up Cobrix version to 2.4.2.

* #1927 Spline _LINEAGE and Atum _INFO files permission alignment (#1934)

* #1927 - testing setup: set both spline _LINEAGE and atum _INFO to hdfs file permissions 733 -> the result on EMR HDFS was 711 (due to 022 umask there) -> evidence of working

* #1927 - cleanup of test settings of 733 fs permissions

* #1927 Atum final version 3.7.0 used instead of the snapshot (same code)

* #1927 comment change

* #1927 - default 644 FS permissions for both _INFO and _LINEAGE files.

* 1937 limit output file size (#1941)

* 1937 limit output file size

* 1937 limit output file size

* 1937 renamings + constants

* 1937 more conditions

* 1937 rename params

* 1937 feedback + script params

* 1937 more feedback

* 1937 final feedback

* #1951: Windows Helper scripts - add missing features
* `ADDITIONAL_JVM_EXECUTOR_CONF`
* Kerberos configuration
* Trust store configuration
* kinit execution option
* `--min-processing-block-size` & `--max-processing-block-size`
* logo improvement

* * --min-processing-block-size -> --min-processing-partition-size
* --max-processing-block-size -> --max-processing-partition-size

* #1869: SparkJobs working with LoadBalanced Menas (#1935)

* `menas.rest.retryCount` - configuration, how many times an url should be retried if failing with retry-able error implemented
* `menas.rest.availability.setup` - configuration, how the url list should be handled
* _Standardization_, _Conformance_ and _HyperConformance_ changed to provide retry count and availability setup to Dao, read from configuration
* `ConfigReader` enhanced and unified to read configurations more easily and universally
* Mockito upgraded to 1.16.42

Co-authored-by: Daniel K <dk1844@gmail.com>

* Feature/1863 mapping table filtering (#1929)

* #1863 mapping cr & mt fitler successfully reuses the same fragment (both using the same named model)
 - todo reuse validation, reuse manipulation methods

* #1863 FilterEdit.js allows reusing filterEdit TreeTable logic between mCR and MT editings

* #1863 mCT editing validation enabled (commons from FilterEdit.js)

* #1863 mCT datatype hinting hinting enabled (commons from DataTypeUtils.js)

* #1863 mCR/MT edit dialog default width=950px, some cleanup
* #1863 bugfixes: directly creating MT with filter (fix on accepting the field), UI fix for MT filter model initialization

* #1863 npm audit fix

* #1863 bugfix: adding new mCR (when no edit MCR dialog has been opened yet) did not work - fixed

* #1863 selecting mapping column from MT schema works (for all schema levels) for edit. TODO = Schema type support

 #1863 mCR - schema-based columns suggested for filter, value types filled in silently during submit, too.

* #1863 bugfix: empty MT - schema may be empty

* #1863 bugfix: removing a filter left a null node - cleanup was needed (otherwise view would fail)
logging cleanup

* #1863 select list item now shows valueType as additionalText, cleanup

* #1863 nonEmptyAndNonNullFilled - map->filter bug fixed.

* #1863 typo for null filter

Co-authored-by: David Benedeki <14905969+benedeki@users.noreply.github.com>

* Update versions for release v2.25.0

* [merge] build fix

* [merge] npm audit fix

* [merge] npm audit fix

* [merge] buildfix (menas->rest_api packaging fix)

* [merge] review updates

Co-authored-by: David Benedeki <benedeki@volny.cz>
Co-authored-by: Saša Zejnilović <zejnils@gmail.com>
Co-authored-by: David Benedeki <14905969+benedeki@users.noreply.github.com>
Co-authored-by: Adrian Olosutean <adi.olosutean@gmail.com>
Co-authored-by: Ruslan Iushchenko <yruslan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR:tested Only for PR - PR was tested by a tester (person)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spline 0.3 doesn't write lineage file to S3
5 participants