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

Empty group following yield causes ClassCastException #125

Open
julianhyde opened this issue Mar 9, 2022 · 1 comment
Open

Empty group following yield causes ClassCastException #125

julianhyde opened this issue Mar 9, 2022 · 1 comment

Comments

@julianhyde
Copy link
Collaborator

If a from expression has a yield clause followed by an empty group, Morel throws ClassCastException.

Here is an example:

- from e in [1,2,3] yield e group;
java.lang.ClassCastException: net.hydromatic.morel.ast.Core$Id cannot be cast to net.hydromatic.morel.ast.Core$Tuple
	at net.hydromatic.morel.compile.Compiler.createRowSinkFactory(Compiler.java:340)
	at net.hydromatic.morel.compile.Compiler.createRowSinkFactory(Compiler.java:317)
	at net.hydromatic.morel.compile.Compiler.compileFrom(Compiler.java:293)
	at net.hydromatic.morel.compile.Compiler.compile(Compiler.java:240)
	at net.hydromatic.morel.compile.Compiler.compileArg(Compiler.java:164)
	at net.hydromatic.morel.compile.Compiler.lambda$compileValDecl$20(Compiler.java:619)
	at net.hydromatic.morel.ast.Core$NonRecValDecl.forEachBinding(Core.java:707)
	at net.hydromatic.morel.compile.Compiler.compileValDecl(Compiler.java:614)
	at net.hydromatic.morel.compile.Compiler.compileDecl(Compiler.java:501)
	at net.hydromatic.morel.compile.Compiler.compileStatement(Compiler.java:88)
	at net.hydromatic.morel.compile.Compiles.prepareDecl(Compiles.java:116)
	at net.hydromatic.morel.compile.Compiles.prepareStatement(Compiles.java:69)
	at net.hydromatic.morel.Shell$SubShell.extracted(Shell.java:480)
	at net.hydromatic.morel.Shell.run(Shell.java:264)
	at net.hydromatic.morel.Shell.main(Shell.java:88)

A similar query without yield is OK:

- from e in [1,2,3] group;
val it = [()] : unit list

Another query with the problem:

- from e in scott.emp where e.job = "CLERK" yield e.deptno group ;
java.lang.ClassCastException: net.hydromatic.morel.ast.Core$Apply cannot be cast to net.hydromatic.morel.ast.Core$Tuple
	at net.hydromatic.morel.compile.Compiler.createRowSinkFactory(Compiler.java:340)
@julianhyde
Copy link
Collaborator Author

This is related to #32. If a step yields a single anonymous field (not a record) how is the subsequent step to refer to it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant