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

Generate fields in REPL for data schemas #693

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal class ReplCodeGeneratorImpl : ReplCodeGenerator {
val result = generator.generate(
schema = schema,
name = name,
fields = false,
fields = true,
extensionProperties = true,
isOpen = isOpen,
visibility = MarkerVisibility.IMPLICIT_PUBLIC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ class CodeGenerationTests : BaseTest() {
val typeName = ReplCodeGeneratorImpl.markerInterfacePrefix
val expectedDeclaration = """
@DataSchema
interface $typeName { }
interface $typeName {
val age: Int
val city: String?
val name: String
val weight: Int?
}

""".trimIndent() + "\n" + expectedProperties(typeName, typeName)

Expand All @@ -94,7 +99,12 @@ class CodeGenerationTests : BaseTest() {
val typeName = ReplCodeGeneratorImpl.markerInterfacePrefix
val expectedDeclaration = """
@DataSchema
interface $typeName { }
interface $typeName {
val age: Int
val city: String?
val name: String
val weight: Int?
}

""".trimIndent() + "\n" + expectedProperties(typeName, typeName)

Expand All @@ -113,7 +123,10 @@ class CodeGenerationTests : BaseTest() {
val type2 = ReplCodeGeneratorImpl.markerInterfacePrefix
val declaration1 = """
@DataSchema(isOpen = false)
interface $type1 { }
interface $type1 {
val city: String?
val name: String
}

val $dfName<$type1>.city: $dataCol<$stringName?> @JvmName("${type1}_city") get() = this["city"] as $dataCol<$stringName?>
val $dfRowName<$type1>.city: $stringName? @JvmName("${type1}_city") get() = this["city"] as $stringName?
Expand All @@ -124,7 +137,11 @@ class CodeGenerationTests : BaseTest() {

val declaration2 = """
@DataSchema
interface $type2 { }
interface $type2 {
val age: Int
val nameAndCity: _DataFrameType1
val weight: Int?
}

val $dfName<$type2>.age: $dataCol<$intName> @JvmName("${type2}_age") get() = this["age"] as $dataCol<$intName>
val $dfRowName<$type2>.age: $intName @JvmName("${type2}_age") get() = this["age"] as $intName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ class ReplCodeGenTests : BaseTest() {

val expected = """
@DataSchema
interface $marker { }
interface $marker {
val age: Int
val city: String?
val name: String
val weight: Int?
}

val $dfName<$marker>.age: $dataCol<$intName> @JvmName("${marker}_age") get() = this["age"] as $dataCol<$intName>
val $dfRowName<$marker>.age: $intName @JvmName("${marker}_age") get() = this["age"] as $intName
Expand All @@ -96,7 +101,9 @@ class ReplCodeGenTests : BaseTest() {
val marker3 = marker + "1"
val expected3 = """
@DataSchema
interface $marker3 : $markerFull { }
interface $marker3 : $markerFull {
override val city: String
}

val $dfName<$marker3>.city: $dataCol<$stringName> @JvmName("${marker3}_city") get() = this["city"] as $dataCol<$stringName>
val $dfRowName<$marker3>.city: $stringName @JvmName("${marker3}_city") get() = this["city"] as $stringName
Expand All @@ -112,7 +119,9 @@ class ReplCodeGenTests : BaseTest() {
val marker5 = marker + "2"
val expected5 = """
@DataSchema
interface $marker5 : $markerFull { }
interface $marker5 : $markerFull {
override val weight: Int
}

val $dfName<$marker5>.weight: $dataCol<$intName> @JvmName("${marker5}_weight") get() = this["weight"] as $dataCol<$intName>
val $dfRowName<$marker5>.weight: $intName @JvmName("${marker5}_weight") get() = this["weight"] as $intName
Expand Down Expand Up @@ -152,7 +161,10 @@ class ReplCodeGenTests : BaseTest() {
val marker = Test2._DataFrameType2::class.simpleName!!
val expected = """
@DataSchema
interface $marker : ${Test2._DataFrameType::class.qualifiedName} { }
interface $marker : ${Test2._DataFrameType::class.qualifiedName} {
val city: String?
val weight: Int?
}

val $dfName<$marker>.city: $dataCol<$stringName?> @JvmName("${marker}_city") get() = this["city"] as $dataCol<$stringName?>
val $dfRowName<$marker>.city: $stringName? @JvmName("${marker}_city") get() = this["city"] as $stringName?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ internal class ReplCodeGeneratorImpl : ReplCodeGenerator {
val result = generator.generate(
schema = schema,
name = name,
fields = false,
fields = true,
extensionProperties = true,
isOpen = isOpen,
visibility = MarkerVisibility.IMPLICIT_PUBLIC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ class CodeGenerationTests : BaseTest() {
val typeName = ReplCodeGeneratorImpl.markerInterfacePrefix
val expectedDeclaration = """
@DataSchema
interface $typeName { }
interface $typeName {
val age: Int
val city: String?
val name: String
val weight: Int?
}

""".trimIndent() + "\n" + expectedProperties(typeName, typeName)

Expand All @@ -94,7 +99,12 @@ class CodeGenerationTests : BaseTest() {
val typeName = ReplCodeGeneratorImpl.markerInterfacePrefix
val expectedDeclaration = """
@DataSchema
interface $typeName { }
interface $typeName {
val age: Int
val city: String?
val name: String
val weight: Int?
}

""".trimIndent() + "\n" + expectedProperties(typeName, typeName)

Expand All @@ -113,7 +123,10 @@ class CodeGenerationTests : BaseTest() {
val type2 = ReplCodeGeneratorImpl.markerInterfacePrefix
val declaration1 = """
@DataSchema(isOpen = false)
interface $type1 { }
interface $type1 {
val city: String?
val name: String
}

val $dfName<$type1>.city: $dataCol<$stringName?> @JvmName("${type1}_city") get() = this["city"] as $dataCol<$stringName?>
val $dfRowName<$type1>.city: $stringName? @JvmName("${type1}_city") get() = this["city"] as $stringName?
Expand All @@ -124,7 +137,11 @@ class CodeGenerationTests : BaseTest() {

val declaration2 = """
@DataSchema
interface $type2 { }
interface $type2 {
val age: Int
val nameAndCity: _DataFrameType1
val weight: Int?
}

val $dfName<$type2>.age: $dataCol<$intName> @JvmName("${type2}_age") get() = this["age"] as $dataCol<$intName>
val $dfRowName<$type2>.age: $intName @JvmName("${type2}_age") get() = this["age"] as $intName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ class ReplCodeGenTests : BaseTest() {

val expected = """
@DataSchema
interface $marker { }
interface $marker {
val age: Int
val city: String?
val name: String
val weight: Int?
}

val $dfName<$marker>.age: $dataCol<$intName> @JvmName("${marker}_age") get() = this["age"] as $dataCol<$intName>
val $dfRowName<$marker>.age: $intName @JvmName("${marker}_age") get() = this["age"] as $intName
Expand All @@ -96,7 +101,9 @@ class ReplCodeGenTests : BaseTest() {
val marker3 = marker + "1"
val expected3 = """
@DataSchema
interface $marker3 : $markerFull { }
interface $marker3 : $markerFull {
override val city: String
}

val $dfName<$marker3>.city: $dataCol<$stringName> @JvmName("${marker3}_city") get() = this["city"] as $dataCol<$stringName>
val $dfRowName<$marker3>.city: $stringName @JvmName("${marker3}_city") get() = this["city"] as $stringName
Expand All @@ -112,7 +119,9 @@ class ReplCodeGenTests : BaseTest() {
val marker5 = marker + "2"
val expected5 = """
@DataSchema
interface $marker5 : $markerFull { }
interface $marker5 : $markerFull {
override val weight: Int
}

val $dfName<$marker5>.weight: $dataCol<$intName> @JvmName("${marker5}_weight") get() = this["weight"] as $dataCol<$intName>
val $dfRowName<$marker5>.weight: $intName @JvmName("${marker5}_weight") get() = this["weight"] as $intName
Expand Down Expand Up @@ -152,7 +161,10 @@ class ReplCodeGenTests : BaseTest() {
val marker = Test2._DataFrameType2::class.simpleName!!
val expected = """
@DataSchema
interface $marker : ${Test2._DataFrameType::class.qualifiedName} { }
interface $marker : ${Test2._DataFrameType::class.qualifiedName} {
val city: String?
val weight: Int?
}

val $dfName<$marker>.city: $dataCol<$stringName?> @JvmName("${marker}_city") get() = this["city"] as $dataCol<$stringName?>
val $dfRowName<$marker>.city: $stringName? @JvmName("${marker}_city") get() = this["city"] as $stringName?
Expand Down