This is a hack which works ( all case pass )
Revisiting: from the face of it, the sql plan is executed twice causing table scanned twice. firstly when result set is needed and secondly after the result set is generated and to actually retrieve the result set content.
In my understanding, The intention of this lies in `RemoteMeta` design. where for the `RemoteMeta` the first execution is delegated to server side where result set is wrapped but not retrieved. and the second execute is to retrieve the content from the wrapped result set. Certainly, the `RemoteMeta` doesn’t deal with `TableScan` anyways. so this is good for RemoteMeta.
but for the ‘Local’ Meta CalciteMetaImpl, both the two executions falls back to the same call, that is wrapping the result set for client use. thus making the Table scanned twice. CalciteMetaImpl certainly does not require the execution to be delegated to remote, so in this case the first execution can be safely skipped.
The fix is a bit hacky though, currently no way provided to distinct these metas.
Julian Hyde let me know what do you think. thanks.