Comments (3)
@flexik Have you considered using the SchemaInferrer?
val inferrer = SchemaInferrer(SchemaType.String, SchemaRule("qty", SchemaType.Int, false), SchemaRule(".*_id", SchemaType.Int))
CsvSource("myfile").withSchemaInferrer(inferrer)
I take your point though that perhaps if you explicitly pass in the schema it should use the schema under-the-hold - we will be looking into this.
from eel-sdk.
@hannesmiller Using SchemaInferrer
yields the exactly same result as using schema directly. No type conversion happens. All Row fields are still String
s.
Updated example with SchemaInferrer
:
import java.io.ByteArrayInputStream
import java.nio.charset.StandardCharsets
import io.eels.{DataTypeRule, SchemaInferrer}
import io.eels.component.csv.CsvSource
import io.eels.schema._
object CsvSourceTypeConversionTest extends App {
val exampleCsvString =
"""A,B,C,D
|1,2.2,3,foo
|4,5.5,6,bar
""".stripMargin
def stream = new ByteArrayInputStream(exampleCsvString.getBytes(StandardCharsets.UTF_8))
val inferrer = SchemaInferrer(
StringType,
DataTypeRule("A", IntType.Signed),
DataTypeRule("B", DoubleType),
DataTypeRule("C", IntType.Signed),
DataTypeRule("D", StringType)
)
val ds = new CsvSource(stream _).withSchemaInferrer(inferrer).toDataStream()
val firstRow = ds.iterator.toIterable.head
val firstRowA = firstRow.get("A")
println(firstRowA) // prints 1 as expected
println(firstRowA.getClass.getTypeName) // prints java.lang.String
assert(firstRowA == 1) // this assertion will fail because firstRowA is not an Int
}
from eel-sdk.
@flexik ok this maybe a bug that was introduced between versions - nevertheless I agree this should match the supplied schema - we will make this a priority for the next release which is looking like the early part of March.
Will keep you posted If we manage to get this resolved in alpha release beforehand.
Regards
Hannes
from eel-sdk.
Related Issues (20)
- Enhanced error handling for HiveWriter HOT 3
- Intermittent test failures
- Add alignToSchema option on datastream
- hive file scan strategy HOT 1
- Fix failing hive compile HOT 1
- `iterator` in DataStream never submits to the executor HOT 4
- Cassandra source & sink
- JdbcSource with DataStream not working HOT 1
- Structs as values in maps not being properly read from Parquet files
- s3 credentials of filesystem are not used in ParquetSink
- support for mapping ArrayTypes to correct (db-vendor-specific) jdbc array types HOT 5
- Issue with Installation of Jboss application server
- Create eel package that doesn't bundle hadoop dependencies
- limit parallelism of ParquetSource to reduce memory footprint
- unresolved dependencies when running sbt package HOT 3
- scala.MatchError when writing date objects to ORC
- Support Hive MAP columns
- Error writing parquet file from JSON with object array HOT 2
- a.parquet/_SUCCESS is not a Parquet file (too small length: 0) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eel-sdk.