Types
Now after creating our own Schema
, DataProvider
and Standard function
, most of the cases can be handled
at this level, but what if you want to store the values in other type than Int
, Float
, Text
...etc,
for example you want to create a type called Song
or Video
and then you can run a query asking
what is the longest video in each directory? or what if you want to create a function that take a TreeNode and return number children nodes?
To allow this level of customization in type system we need to make it easy to integrate with the parser, type checker and execution engine? we can't support every possible type in the engine.
But .... What if we support 0 types 🤔 .... what if the types are not primitives in the engine but defined in the Standard library or the SDK?
Moving the Types from the Engine to the SDK level
This idea is inspired by Chris Lattner
design in Mojo and Swift programming languages,
by default the Engine has some built in predefined types like Integer
, Float
, Boolean
...etc, it know very well
what operators can work with them, how can cast them, this can work well and programming languages gives you the ability to
compose types and create Structured data types like List
, File
, GamePlayer
...etc, but what if we create a way to define your own type,
and define how the Engine or the Compiler can deal with it, define what operators work with it, in this case we can define Integer
, Float
as part of the Standard library or in our case the SDK, and that also gives the SDK user the power to built any type he want to make it integrated
well in all part of the Query Engine.
Lets for example say we want to create type called IntPair
and define attributes and operators for it,
Creating a custom DataType
Now if we create a new Function with Signature that accept IntPair and we pass Int, it will report an error, but now we created a Type but to create a Value with this type we need to create a Custom Value too (Creating the IntPairValue as Custom value).