Closed YuMingLiao closed 5 years ago
Very cool! I like how straightforward the implementation is and that the macros can nest.
What happens if a temp relvar name overlaps with/shadows an existing name? I suspect we should be proactive and make that an error. What do you think?
Thanks!
I think the error is covered since I use runState evalDatabaseContextExpr (Assign ...) context
, the existing code.
TutorialD (master/main): :importexample date
TutorialD (master/main): :showexpr WITH (s AS p) s
ERR: RelationTypeMismatchError [Attribute "s#" TextAtomType,Attribute "sname" TextAtomType,Attribute "status" IntegerAtomType,Attribute "city" TextAtomType] [Attribute "p#" TextAtomType,Attribute "pname" TextAtomType,Attribute "color" TextAtomType,Attribute "weight" IntegerAtomType,Attribute "city" TextAtomType]
TutorialD (master/main): :showexpr WITH (a AS s,a AS p) a
ERR: RelationTypeMismatchError [Attribute "s#" TextAtomType,Attribute "sname" TextAtomType,Attribute "status" IntegerAtomType,Attribute "city" TextAtomType] [Attribute "p#" TextAtomType,Attribute "pname" TextAtomType,Attribute "color" TextAtomType,Attribute "weight" IntegerAtomType,Attribute "city" TextAtomType]
code reusing Hooray!
But what if the attributes do match? Is there still an error? I would expect a RelVarAlreadyDefinedError
.
Oh, I see. It's not a correct error. I need to define then assign.
Done!
TutorialD (master/main): :importexample date
TutorialD (master/main): :showexpr WITH (s AS p) s
ERR: RelVarAlreadyDefinedError "s"
TutorialD (master/main): :showexpr WITH (a AS s,a AS p) a
ERR: RelVarAlreadyDefinedError "a"
I've made a first pass, using the relation expression state. I use AS instead of := at a first pass just try to help me implement it from SQL WITH. However, It can be changed for any good reason. It supports multiple views. However, it can only reference previous ones.