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

[Destination MSSQLv2] Implement typed insertions #50434

Merged
merged 59 commits into from
Jan 15, 2025

Conversation

gosusnp
Copy link
Contributor

@gosusnp gosusnp commented Dec 28, 2024

What

Handle typed insertion of data.

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

Copy link

vercel bot commented Dec 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 4:56pm

Co-authored-by: Jonathan Pearlin <jpearlin1@gmail.com>
Base automatically changed from gosusnp/mssql-v2-check-tests to move/destination-mssql-v2 December 30, 2024 18:28
}
} else {
try {
when (value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It may make this cleaner to encapsulate this logic in an extension function on the value -- something like value.setStatementValue(statement=statement). The extension function would encapsulate this when block, making this code easier to test separate from the type conversion expectations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

.filter { field -> field.name !in airbyteFields }
.map { field ->
try {
when (field.type.type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above...this feels like another good use of an extension function on the type to encapsulate this conversion logic and make it easier to test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

private val dataSourceFactory: MSSQLDataSourceFactory
) : DestinationWriter {
override fun createStreamLoader(stream: DestinationStream): StreamLoader {
val dataSource = dataSourceFactory.getDataSource(config)
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to do this in the constructor/init/post construct method. Otherwise, we are creating a data source per stream, which means d x s connections instead of just d connections if the data source is shared between streams (preferred to limit connections).

}
}
} catch (ex: Exception) {
KotlinLogging.logger {}.error(ex) { ex.message }
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be a file level variable to avoid creating the logger each time that the code catches.

@gosusnp gosusnp changed the title wip [Destination MSSQLv2] Implement typed insertions Jan 8, 2025
@gosusnp gosusnp marked this pull request as ready for review January 8, 2025 19:03
@gosusnp gosusnp requested a review from a team as a code owner January 8, 2025 19:03
@octavia-squidington-iv octavia-squidington-iv requested review from a team January 8, 2025 19:04
is BooleanValue -> setAsBooleanValue(idx, value)
is DateValue -> setAsDateValue(idx, value)
is IntegerValue -> setAsIntegerValue(idx, value)
NullValue -> setAsNullValue(idx, field.type.type)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this missing an is?

is BooleanValue -> "boolean"
is DateValue -> "string"
is IntegerValue -> "integer"
NullValue -> "null"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment...is this missing a leading is?

when (field.type.type) {
is StringType -> getStringValue(field.name)
is ArrayType -> getArrayValue(field.name)
ArrayTypeWithoutSchema -> getArrayValue(field.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

More mixes of is type and just type. If both work, we should be consistent here and choose one approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because we are mixing two concepts, AirbyteValue is a sealed interface and we are mixing data object and value class. is refers to value class, cases where is is omitted are data object.
That's also how intellij auto generates the support all cases for a sealed interface, at least with the default style config.

Copy link
Contributor

@jdpgrailsdev jdpgrailsdev left a comment

Choose a reason for hiding this comment

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

:shipit: One question/comment on the inconsistent use of the is keyword in when blocks.

@jdpgrailsdev jdpgrailsdev force-pushed the move/destination-mssql-v2 branch from 069a0bc to b564021 Compare January 14, 2025 16:15
@gosusnp gosusnp merged commit 134f368 into move/destination-mssql-v2 Jan 15, 2025
17 of 22 checks passed
@gosusnp gosusnp deleted the gosusnp/msssql-v2-basic-inserts branch January 15, 2025 16:51
@octavia-squidington-iv octavia-squidington-iv requested a review from a team January 15, 2025 16:51
jdpgrailsdev added a commit that referenced this pull request Jan 17, 2025
Co-authored-by: Jonathan Pearlin <jonathan@airbyte.io>
jdpgrailsdev added a commit that referenced this pull request Jan 21, 2025
Co-authored-by: Jonathan Pearlin <jonathan@airbyte.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants