I am just using the parser only. Based on the test cases I wrote the
following code:
SqlValidatorWithHints validator = SqlValidatorUtil.newValidator(
new SqlStdOperatorTable(),
new MySqlValidatorCatalogReader(),
new SqlTypeFactoryImpl(new MyRelDataTypeSystemImpl()),
SqlConformanceEnum.STRICT_2003);
SqlAdvisor advisor = new SqlAdvisor(validator,
SqlParser.Config.DEFAULT);
String sql = "select * FROM s^";
SqlParserUtil.StringAndPos sap = SqlParserUtil.findPos(sql);
List<SqlMoniker> results = advisor.getCompletionHints(sql,
sap.cursor, new String[]{null});
I am wondering where I can feed the schema/table information in the code.
Regards,
Rahul
On Thu, Jan 10, 2019 at 4:03 PM Vladimir Sitnikov <
[email protected]> wrote:
> Rahul Raj > Can anyone point me to a standalone example of SQL Advisor? I
> went through
> Rahul Raj> the test cases, but the test setups were slightly complicated to
> understand.
>
> It heavily depends on the way you use Calcite.
> Do you use java.sql.Connection?
> Do you use just Parser?
>
> Here's how I use advisor.
>
> I add "get_hints" function to the schema:
>
> https://github.com/vlsi/mat-calcite-plugin/blob/add281383967f957b4188e623c964bf00b03aa6f/MatCalcitePlugin/src/com/github/vlsi/mat/calcite/neo/PackageSchema.java#L103
>
> Then I execute it via SQL interface:
>
> https://github.com/vlsi/mat-calcite-plugin/blob/add281383967f957b4188e623c964bf00b03aa6f/MatCalcitePlugin/src/com/github/vlsi/mat/calcite/editor/CalciteContentAssistantProcessor.java#L54-L56
>
> Note, there's undocumented API (
>
> https://github.com/vlsi/mat-calcite-plugin/blob/add281383967f957b4188e623c964bf00b03aa6f/MatCalcitePlugin/src/com/github/vlsi/mat/calcite/editor/CalciteContentAssistantProcessor.java#L69-L74
> ), however I don't really remember if there's much difference between the
> two. Note that undocumented might disappear at any moment though.
>
> Vladimir
>
--
<a href="http://www.spreadfirefox.com/?q=affiliates&id=0&t=1"><textarea
rows="3" cols="40"><a href="
http://www.spreadfirefox.com/?q=affiliates&id=0&t=1">Get Firefox!</a>