Hello

I'm developing an adapter for my custom data source. My adapter uses hints to 
tailor query calls to my underlying data source. Did I understand it correctly 
that hints have to be defined "outside" of an adapter, i.e., at the location 
where the connection is defined?

I'm currently wrapping a JDBC connection with a hook for hint strategies. Is 
that the correct way to do that? It looks quite odd and wrong, especially since 
hooks should only be used for debugging and testing according to the 
documentation. I would rather expect hint strategies to be defined in my 
adapter directly (or the model.json or as a property along with the connection).

Thanks for your help!

try (Hook.Closeable closeable = 
Hook.SQL2REL_CONVERTER_CONFIG_BUILDER.addThread((Holder<SqlToRelConverter.Config>
 configHolder) -> {
    HintStrategyTable strategies = HintStrategyTable.builder()
            .hintStrategy("index", (hint, rel) -> true)
            .build();
    configHolder.accept(config -> config.withHintStrategyTable(strategies));
})) {
    String sql = """
            SELECT *
            FROM test /*+ index(A) */""";

    final Properties info = new Properties();
    info.put("model", 
requireNonNull(getClass().getResource("/model.json")).getPath());

    final Connection connection = DriverManager.getConnection("jdbc:calcite:", 
info);

    final Statement statement = connection.createStatement();
    final ResultSet rs = statement.executeQuery(sql);

    ...
}

Reply via email to