You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by xuedong luan <lu...@gmail.com> on 2016/09/09 09:39:16 UTC
Problem with elasticsearch adapter
Hi Calcite devs,
I have problem when i am using elasticsearch adapter to query a index
from elasticsearch,Following
is the sample code:
Properties properties = new Properties();
properties.setProperty("caseSensitive", "false");
PreparedStatement statement2 = null;
Connection conn = null;
try {
Class.forName("org.apache.calcite.jdbc.Driver");
String url =
"jdbc:calcite:schemaFactory=org.apache.calcite.adapter.elasticsearch.ElasticsearchSchemaFactory;
schema.coordinates={'127.0.0.1':9300};
schema.userConfig={'cluster.name': 'luan'}; schema.index=vip";
conn = DriverManager.getConnection(url, properties);
String sql = "select \"username\" from \"vipuser\"";
statement2 = conn.prepareStatement(sql);
ResultSet set = statement2.executeQuery();
while(set.next()){
logger.info(set.getString(1));
}
}catch (Exception e){
e.printStackTrace();
}
And exception is :
2016-09-09 16:59:40,084 [TRACE]
[org.apache.calcite.runtime.CalciteException--main]: SqlValidatorException
org.apache.calcite.sql.validate.SqlValidatorException: Column 'username'
not found in any table
I hava seen the code validateSelectList() in SqlValidatorImpl.java. And
i do not see code of geting mapping from a elasticsearch,only
in validateFrom() function , calcite will make a request to elasticsearch
to validator tablename. can any one help me ?
thanks