Github user aertoria commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/262#discussion_r126823141
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/parse/SelectStatement.java ---
@@ -267,6 +267,12 @@ public LimitNode getLimit() {
}
@Override
+ public Double getTableSamplingRate(){
+ if(fromTable==null || !(fromTable instanceof
ConcreteTableNode)) return null;
+ return ((ConcreteTableNode)fromTable).getTableSamplingRate();
--- End diff --
This is a valid concern and I also have thought about it during developing.
Below is my thought process. Please correct me @JamesRTaylor
So for a join statment, when there are two concrete tables, during the
early stage of the plan preparation phase, they will exist inside
`select-statement` object as one `JoinTableNode` object. During this time,
`getTableSamplingRate` method is not called. Even if in the future some one
calls it, it will return null because type safety check inside method.
Later on, during the plan compiling phase, this `select-statement` is going
through JoinCompiler, where two new `select-statment` objects will be created
with each one has a brand new `fromTable` object. `FromTable` object is
populated from `joinTable` object which essentially is the end product when
`JoinTable.Compile()` spliting the original `JoinTableNode` into two. For this
code please check Line 136 of `JoinCompiler.java` (Link below)
https://github.com/apache/phoenix/blob/ecd287f618470d1e34082c20feb9939cbb0ea65b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
So by the time `getTableSamplingRate` method is called, which is during the
"getting iterator phase", each select statments will have exactly one
`ConcreteTableNode` with its corresponding sampling rate associate with it.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---