Skip to content

Conversation

@nord-erik
Copy link
Contributor

@nord-erik nord-erik commented Oct 28, 2025

this commit introduces a new way to write from Spark SQL interval types to Neo4j duration type.
commit is additive, i.e. the previous method to write Neo4j duration type via custom struct is
still possible, and should therefore be backwards compatible.

Fixes CONN-341

class SparkToNeo4jDataConverter extends DataConverter[Value] {

override def convert(value: Any, dataType: DataType): Value = {
dataType match {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking into how to re-write this to still match on value (and incorporate below)

@nord-erik nord-erik force-pushed the en/feat-native-types branch 4 times, most recently from c564f4e to b8a5787 Compare November 7, 2025 08:27
this commit introduces a new way to write from Spark SQL interval types to Neo4j duration type.
commit is additive, i.e. the previous method to write Neo4j duration type via custom struct is
still possible, and should therefore be backwards compatible.

Fixes CONN-341
@nord-erik nord-erik force-pushed the en/feat-native-types branch from b8a5787 to 078fcf0 Compare November 7, 2025 08:27

class DataSourceWriterTSE extends SparkConnectorScalaBaseTSE {
val sparkSession = SparkSession.builder().getOrCreate()
val sparkSession: SparkSession = SparkSession.builder().getOrCreate()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: not sure adding the explicit type really helps readability here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree

assertEquals(expected, records)
}

private def writeAndGetInterval(expectedDt: Class[_ <: DataType], sql: String): Value = {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd put the caller before the callee (I find it easier to read from top to bottom, than scrolling back and forth, but that's just a personal preference)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do

}

@Test
def `should write nodes with native Neo4j durations when passed DayTimeIntervalType`(): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: would it be possible to turn all of these test into a single parameterized test? it would make it easier to check whether we've got exhaustive checks on all these interval variants

Copy link
Contributor

@fbiville fbiville Nov 7, 2025

Choose a reason for hiding this comment

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

question: I can see INTERVAL DAY TO SECOND and INTERVAL YEAR TO MONTH covered, but about all the others? (which would be easier to add to a parameterized test btw)

  • INTERVAL YEAR
  • INTERVAL MONTH
  • INTERVAL DAY
  • INTERVAL DAY TO HOUR
  • INTERVAL DAY TO MINUTE
  • INTERVAL HOUR
  • INTERVAL HOUR TO MINUTE
  • INTERVAL HOUR TO SECOND
  • INTERVAL MINUTE
  • INTERVAL MINUTE TO SECOND
  • INTERVAL SECOND

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into parametrized tests in sacala/junit4 env, but at that time it was just a few cases. Can look into your suggested intervals and look into re-adding parameterized

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.

3 participants