-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement SQL server type parsing (#72)
* Implement SQL server type parsing ## Scope: - Implement intermediate abstraction ArcaneSchema for data schema translation - Add ability to read columns schema with types to `MsSqlConnection` * Remove the StructType as it is not used right now * Review fixes
- Loading branch information
Showing
4 changed files
with
121 additions
and
15 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
framework/arcane-framework/src/main/scala/models/ArcaneSchema.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.sneaksanddata.arcane.framework | ||
package models | ||
|
||
/** | ||
* ArcaneSchema is a type alias for a sequence of fields or structs. | ||
*/ | ||
type ArcaneSchema = Seq[Field] | ||
|
||
/** | ||
* Companion object for ArcaneSchema. | ||
*/ | ||
object ArcaneSchema: | ||
/** | ||
* Creates an empty ArcaneSchema. | ||
* @return An empty ArcaneSchema. | ||
*/ | ||
def empty(): ArcaneSchema = Seq.empty | ||
|
||
|
||
/** | ||
* Types of fields in ArcaneSchema. | ||
*/ | ||
enum ArcaneType: | ||
case LongType | ||
case ByteArrayType | ||
case BooleanType | ||
case StringType | ||
case DateType | ||
case TimestampType | ||
case DateTimeOffsetType | ||
case BigDecimalType | ||
case DoubleType | ||
case IntType | ||
case FloatType | ||
case ShortType | ||
case TimeType | ||
|
||
/** | ||
* Field is a case class that represents a field in ArcaneSchema | ||
* @param name The name of the field. | ||
* @param fieldType The type of the field. | ||
*/ | ||
case class Field(name: String, fieldType: ArcaneType) |
26 changes: 24 additions & 2 deletions
26
framework/arcane-framework/src/main/scala/services/base/SchemaProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,41 @@ | ||
package com.sneaksanddata.arcane.framework | ||
package services.base | ||
|
||
import models.ArcaneType | ||
|
||
import scala.concurrent.Future | ||
|
||
/** | ||
* Type class that represents the ability to add a field to a schema. | ||
* @tparam Schema The type of the schema. | ||
*/ | ||
trait CanAdd[Schema] : | ||
/** | ||
* Adds a field to the schema. | ||
* | ||
* @return The schema with the field added. | ||
*/ | ||
extension (a: Schema) def addField(fieldName: String, fieldType: ArcaneType): Schema | ||
|
||
/** | ||
* Represents a provider of a schema for a data produced by Arcane. | ||
* | ||
* @tparam Schema The type of the schema. | ||
*/ | ||
trait SchemaProvider[Schema] { | ||
trait SchemaProvider[Schema: CanAdd] { | ||
|
||
type SchemaType = Schema | ||
/** | ||
* Gets the schema for the data produced by Arcane. | ||
* | ||
* @return A future containing the schema for the data produced by Arcane. | ||
*/ | ||
def getSchema: Future[Schema] | ||
def getSchema: Future[SchemaType] | ||
|
||
/** | ||
* Gets an empty schema. | ||
* | ||
* @return An empty schema. | ||
*/ | ||
def empty: SchemaType | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters