Hi Mans,
`LookupTableSource` used to look up rows from external storage system by
given keys, it's very suitable for Key/Value storage system (e.g Redis,
HBase), or storage system with key concept (e.g, Mysql, Hive). `
ScanTableSource` is used to scan all rows from an external storage system.
Some connectors implement both `LookupTableSource` and `ScanTableSource`
because they both have two abilities. (e.g Hive, HBase, JDBC).

> 1. Are there other examples/documentation on how to create a query that
uses it vs ScanTableSource ?
If SQL use Lookup join[1] syntax, optimizer would expect underlying table
source which related to the right side has implemented `LookupTableSource`.
please note only right side is `LookupTableSource`, left side is still
`ScanTableSource`.
If SQL uses non-Lookup join syntax (e.g Regular join, Interval join,
temporal join, window join)[1], the optimizer would expect the underlying
table source to have implemented `ScanTableSource`.

> 2. Are there any best practices for using this interface ?
What do you expect to find in `a best practice for using this interface`?
For a TableApi/SQL user, maybe there are not many difficult problems to use
a `LookupTableSource` because they would not deal with `LookupTableSource`
explicitly, they only use Lookup join[1] syntax.

> 3. How does the planner decide to use LookupTableSource vs
ScanTableSource ?
Please see the first response above

> 4. Are there some hints/etc that can be given to the planner to force it
to use LookupTableSource ?
No, there is no need to do this. useLookup join[1] syntax if need use
`LookupTableSource`,

> 5. Is this used only for joins or for regular queries ?
Please see the first response above

> 6. Can it be used for regular joins ? If so, is there any
documentation/example ?
If the underlying tablesource only implements `ScanTableSource`, then the
user could not use it in lookup join. If the underlying tablesource only
implements `LookupTableSource`, then the user could not use it in non-Lookup
join syntax (e.g Regular join, Interval join, temporal join, window join).
Otherwise an exception would be thrown out in the compile phase.

[1]
https://ci.apache.org/projects/flink/flink-docs-release-1.13/docs/dev/table/sql/queries/joins/

Best regards,
JING ZHANG


M Singh <mans2si...@yahoo.com> 于2021年7月7日周三 上午8:23写道:

> Hey Folks:
>
> I am trying to understand how LookupTableSource works and have a few
> questions:
>
> 1. Are there other examples/documentation on how create a query that uses
> it vs ScanTableSource ?
> 2. Are there any best practices for using this interface ?
> 3. How does the planner decide to use LookupTableSource vs ScanTableSource
> ?
> 4. Are there some hints/etc that can be given to the planner to force it
> to use LookupTableSource ?
> 5. Is this used only for joins or for regular queries ?
> 6. Can it be used for regular joins ? If so, is there any
> documentation/example ?
>
> Thanks for your help.
>
> Mans
>

Reply via email to