Hi,
For Ignite thick client, the column names for a given sql query are coming up
as expected with the following code:
public class ClientNode {
public static void main(String[] args) {
IgniteConfiguration igniteCfg = new IgniteConfiguration();
igniteCfg.setClientMode(true);
Ignite ignite = Ignition.start(igniteCfg);
IgniteCache foo = ignite.getOrCreateCache("foo");
SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM person");
FieldsQueryCursor cursor = foo.query(sql);
int count = cursor.getColumnsCount();
List<String> columnNames = new ArrayList<>();
for (int i = 0; i < count; i++) {
String columnName = cursor.getFieldName(i);
columnNames.add(columnName);
}
System.out.println("columnNames:::"+columnNames);
} }
Output:
columnNames:::[ID, NAME, LAST_NAME, AGE, CITY_ID, EMAIL_ID]
On the other hand, for thin client, the column names are coming up as empty
list.
The following is the code:
public class ClientNode {
public static void main(String[] args) {
ClientConfiguration clientConfig = new ClientConfiguration();
cc.setUserName("username");
cc.setUserPassword("password");
IgniteClient thinClient = Ignition.startClient(clientConfig);
SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM person");
FieldsQueryCursor cursor = thinClient.query(sql);
int count = cursor.getColumnsCount();
List<String> columnNames = new ArrayList<>();
for (int i = 0; i < count; i++) {
String columnName = cursor.getFieldName(i);
columnNames.add(columnName);
}
System.out.println("columnNames:::"+columnNames);
} }
Output:
columnNames:::[ ]
While using IgniteCache.query(SqlFieldsQuery), the column names are coming up.
But while using IgniteClient.query(SqlFieldsQuery), the column names are not
coming up. Are we missing any configurations? Is there something wrong in the
code? And also is there anyway in which we can identify the datatype of columns
given in the query! We are looking for the datatype of the columns in the query
but not the datatype of columns in the table!
Any help here will be much appreciated!
Thanks in advance!
Regards,
Shravya Nethula,
BigData Developer,
[cid:066886cc-0cdf-4e72-b66b-181ae1642679]
Hyderabad.