Skip to content

Added support for compilation overrides in Data Preparations#1818

Merged
fernst merged 8 commits intomainfrom
add-compilation-overrides-support-data-preparation
Sep 4, 2024
Merged

Added support for compilation overrides in Data Preparations#1818
fernst merged 8 commits intomainfrom
add-compilation-overrides-support-data-preparation

Conversation

@fernst
Copy link
Copy Markdown
Collaborator

@fernst fernst commented Aug 27, 2024

No description provided.

@fernst fernst requested a review from Ekrekr August 27, 2024 01:50
@fernst fernst requested a review from Ekrekr August 28, 2024 14:22
Comment on lines +1083 to +1095
// Generate Base64 encoded representation of the YAML.
const dataPreparationAsObject = loadYaml(resolvedYaml);
const dataPreparationDefinition = verifyObjectMatchesProto(
dataform.dataprep.DataPreparation,
dataPreparationAsObject as {
[key: string]: any;
},
VerifyProtoErrorBehaviour.DEFAULT
);
const base64encodedContents = encode64(
dataform.dataprep.DataPreparation,
dataPreparationDefinition
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems like quite an indirect way of testing. It would be better to follow the pattern of the other tests, and just write the expected proto output of dataPreparationContents directly, rather than writing a YAML and converting it. The intermediate format isn't important here - just the final entry in the compiled graph.

Comment on lines +184 to +188
return dataform.dataprep.TableReference.create({
project: resolvedTarget.database,
dataset: resolvedTarget.schema,
table: resolvedTarget.name
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dataset and project may not always be set, so this will end up creating a target proto with potentially empty values.

E.g. I think you need to do:

const dataprepTarget = dataform.dataprep.TableReference.create({table: resolvedTarget.name})
if (resolvedTarget.database) {
  dataprepTarget.project = resolvedTarget.database
}

(I'm avoid the spread operator because they can cause uncaught bugs fairly easily).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

return resolvedDataPreparation;
}

function applySessionDefaultsToTableReference(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To mirror the naming of applySessionToTarget, this would better be applySessionToTableReference instead

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

}
}

function resolveSourcesAndDestinations(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: rename to something like applySessionToDataPreparationContents

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@fernst fernst requested a review from Ekrekr September 3, 2024 19:13
@fernst fernst merged commit 674b1e6 into main Sep 4, 2024
@fernst fernst deleted the add-compilation-overrides-support-data-preparation branch September 4, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants