-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Destination MSSQLv2] Implement typed insertions #50434
Conversation
This reverts commit 90aa35e.
Co-authored-by: Jonathan Pearlin <jpearlin1@gmail.com>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Co-authored-by: Jonathan Pearlin <jpearlin1@gmail.com>
} | ||
} else { | ||
try { | ||
when (value) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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.
...2/src/test-integration/kotlin/io/airbyte/integrations/destination/mssql/v2/MSSQLCheckTest.kt
Outdated
Show resolved
Hide resolved
is BooleanValue -> setAsBooleanValue(idx, value) | ||
is DateValue -> setAsDateValue(idx, value) | ||
is IntegerValue -> setAsIntegerValue(idx, value) | ||
NullValue -> setAsNullValue(idx, field.type.type) |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question/comment on the inconsistent use of the is
keyword in when
blocks.
069a0bc
to
b564021
Compare
Co-authored-by: Jonathan Pearlin <jonathan@airbyte.io>
Co-authored-by: Jonathan Pearlin <jonathan@airbyte.io>
What
Handle typed insertion of data.
Can this PR be safely reverted and rolled back?