You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Shravya Nethula <sh...@aline-consulting.com> on 2020/11/03 04:50:58 UTC
How to get column names for a query in Ignite thin client mode
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.
Re: How to get column names for a query in Ignite thin client mode
Posted by Shravya Nethula <sh...@aline-consulting.com>.
Thank you Ilya
Regards,
Shravya Nethula,
BigData Developer,
[cid:2d89cf9f-aa3f-4a88-aea2-70b3dfe9cb3e]
Hyderabad.
________________________________
From: Ilya Kasnacheev <il...@gmail.com>
Sent: Wednesday, November 11, 2020 7:46 PM
To: user@ignite.apache.org <us...@ignite.apache.org>
Cc: Bhargav Kunamneni <bh...@aline-consulting.com>
Subject: Re: How to get column names for a query in Ignite thin client mode
Hello!
You can find out data types while using JDBC API, by using ResultSetMetaData and DatabaseMetaData interfaces.
Regards,
--
Ilya Kasnacheev
пн, 9 нояб. 2020 г. в 10:42, Shravya Nethula <sh...@aline-consulting.com>>:
Hi,
Any update on this?
Any help is much apppreciated!
Regards,
Shravya Nethula,
BigData Developer,
[cid:175b7a972609f4c27214]
Hyderabad.
________________________________
From: Shravya Nethula <sh...@aline-consulting.com>>
Sent: Thursday, November 5, 2020 4:54 PM
To: user@ignite.apache.org<ma...@ignite.apache.org> <us...@ignite.apache.org>>
Cc: Bhargav Kunamneni <bh...@aline-consulting.com>>
Subject: Re: How to get column names for a query in Ignite thin client mode
Hi Alex,
Thank you for the information.
Is there a possibility of getting the datatypes in thick client mode?
Regards,
Shravya Nethula,
BigData Developer,
[cid:175b7a97260ae1a39463]
Hyderabad.
________________________________
From: Alex Plehanov <pl...@gmail.com>>
Sent: Thursday, November 5, 2020 12:03 PM
To: user@ignite.apache.org<ma...@ignite.apache.org> <us...@ignite.apache.org>>
Cc: Bhargav Kunamneni <bh...@aline-consulting.com>>
Subject: Re: How to get column names for a query in Ignite thin client mode
Currently, only field names can be obtained, there is no information about field data types in thin client protocol.
ср, 4 нояб. 2020 г. в 13:58, Shravya Nethula <sh...@aline-consulting.com>>:
Ilya and Alex,
Thank you for information.
Can you please also suggest how to get the datatypes of those columns obtained from the query?
Regards,
Shravya Nethula,
BigData Developer,
[cid:175b7a97260d11dd2572]
Hyderabad.
________________________________
From: Alex Plehanov <pl...@gmail.com>>
Sent: Tuesday, November 3, 2020 12:13 PM
To: user@ignite.apache.org<ma...@ignite.apache.org> <us...@ignite.apache.org>>
Subject: Re: How to get column names for a query in Ignite thin client mode
Columns information is read by thin-client only after the first data request, so you need to read at least one row to get columns.
вт, 3 нояб. 2020 г. в 09:31, Ilya Kazakov <ka...@gmail.com>>:
Hello, Shravya! It is very interesting! I am trying to reproduce your case, and what I see. I can see column names in the thin client only after query execution.
For example:
ClientConfiguration clientConfig = new ClientConfiguration().setAddresses("127.0.0.1");
try(IgniteClient thinClient = Ignition.startClient(clientConfig)){
SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM T1");
FieldsQueryCursor cursor = thinClient.query(sql);
cursor.getAll();
int count = cursor.getColumnsCount();
System.out.println(count);
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);
}
But if this is the correct behavior I do not know yet, I will try to find out.
--------------------------------
Ilya Kazakov
вт, 3 нояб. 2020 г. в 12:51, Shravya Nethula <sh...@aline-consulting.com>>:
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:175b7a9725fbe2ca0301]
Hyderabad.
Re: How to get column names for a query in Ignite thin client mode
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
You can find out data types while using JDBC API, by using
ResultSetMetaData and DatabaseMetaData interfaces.
Regards,
--
Ilya Kasnacheev
пн, 9 нояб. 2020 г. в 10:42, Shravya Nethula <
shravya.nethula@aline-consulting.com>:
> Hi,
>
> Any update on this?
> Any help is much apppreciated!
>
> Regards,
>
> Shravya Nethula,
>
> BigData Developer,
>
>
> Hyderabad.
>
> ------------------------------
> *From:* Shravya Nethula <sh...@aline-consulting.com>
> *Sent:* Thursday, November 5, 2020 4:54 PM
> *To:* user@ignite.apache.org <us...@ignite.apache.org>
> *Cc:* Bhargav Kunamneni <bh...@aline-consulting.com>
> *Subject:* Re: How to get column names for a query in Ignite thin client
> mode
>
> Hi Alex,
>
> Thank you for the information.
> Is there a possibility of getting the datatypes in thick client mode?
>
> Regards,
>
> Shravya Nethula,
>
> BigData Developer,
>
>
> Hyderabad.
>
> ------------------------------
> *From:* Alex Plehanov <pl...@gmail.com>
> *Sent:* Thursday, November 5, 2020 12:03 PM
> *To:* user@ignite.apache.org <us...@ignite.apache.org>
> *Cc:* Bhargav Kunamneni <bh...@aline-consulting.com>
> *Subject:* Re: How to get column names for a query in Ignite thin client
> mode
>
> Currently, only field names can be obtained, there is no information about
> field data types in thin client protocol.
>
> ср, 4 нояб. 2020 г. в 13:58, Shravya Nethula <
> shravya.nethula@aline-consulting.com>:
>
> Ilya and Alex,
>
> Thank you for information.
> Can you please also suggest how to get the datatypes of those columns
> obtained from the query?
>
>
> Regards,
>
> Shravya Nethula,
>
> BigData Developer,
>
>
> Hyderabad.
>
>
> ------------------------------
> *From:* Alex Plehanov <pl...@gmail.com>
> *Sent:* Tuesday, November 3, 2020 12:13 PM
> *To:* user@ignite.apache.org <us...@ignite.apache.org>
> *Subject:* Re: How to get column names for a query in Ignite thin client
> mode
>
> Columns information is read by thin-client only after the first data
> request, so you need to read at least one row to get columns.
>
> вт, 3 нояб. 2020 г. в 09:31, Ilya Kazakov <ka...@gmail.com>:
>
> Hello, Shravya! It is very interesting! I am trying to reproduce your
> case, and what I see. I can see column names in the thin client only after
> query execution.
>
> For example:
>
> ClientConfiguration clientConfig = new ClientConfiguration().setAddresses("127.0.0.1");
> try(IgniteClient thinClient = Ignition.startClient(clientConfig)){
> SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM T1");
> FieldsQueryCursor cursor = thinClient.query(sql);
> cursor.getAll();
> int count = cursor.getColumnsCount();
> System.out.println(count);
> 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);
> }
>
>
> But if this is the correct behavior I do not know yet, I will try to find
> out.
>
> --------------------------------
> Ilya Kazakov
>
> вт, 3 нояб. 2020 г. в 12:51, Shravya Nethula <
> shravya.nethula@aline-consulting.com>:
>
> 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,
>
>
> Hyderabad.
>
>
Re: How to get column names for a query in Ignite thin client mode
Posted by Shravya Nethula <sh...@aline-consulting.com>.
Hi,
Any update on this?
Any help is much apppreciated!
Regards,
Shravya Nethula,
BigData Developer,
[cid:7572d2f4-9800-4bf2-9ca4-85f6f18e44c6]
Hyderabad.
________________________________
From: Shravya Nethula <sh...@aline-consulting.com>
Sent: Thursday, November 5, 2020 4:54 PM
To: user@ignite.apache.org <us...@ignite.apache.org>
Cc: Bhargav Kunamneni <bh...@aline-consulting.com>
Subject: Re: How to get column names for a query in Ignite thin client mode
Hi Alex,
Thank you for the information.
Is there a possibility of getting the datatypes in thick client mode?
Regards,
Shravya Nethula,
BigData Developer,
[cid:0d6f1002-8e08-4cec-a2dd-85d2391ee2f7]
Hyderabad.
________________________________
From: Alex Plehanov <pl...@gmail.com>
Sent: Thursday, November 5, 2020 12:03 PM
To: user@ignite.apache.org <us...@ignite.apache.org>
Cc: Bhargav Kunamneni <bh...@aline-consulting.com>
Subject: Re: How to get column names for a query in Ignite thin client mode
Currently, only field names can be obtained, there is no information about field data types in thin client protocol.
ср, 4 нояб. 2020 г. в 13:58, Shravya Nethula <sh...@aline-consulting.com>>:
Ilya and Alex,
Thank you for information.
Can you please also suggest how to get the datatypes of those columns obtained from the query?
Regards,
Shravya Nethula,
BigData Developer,
[cid:1759717cc2dd11dd2572]
Hyderabad.
________________________________
From: Alex Plehanov <pl...@gmail.com>>
Sent: Tuesday, November 3, 2020 12:13 PM
To: user@ignite.apache.org<ma...@ignite.apache.org> <us...@ignite.apache.org>>
Subject: Re: How to get column names for a query in Ignite thin client mode
Columns information is read by thin-client only after the first data request, so you need to read at least one row to get columns.
вт, 3 нояб. 2020 г. в 09:31, Ilya Kazakov <ka...@gmail.com>>:
Hello, Shravya! It is very interesting! I am trying to reproduce your case, and what I see. I can see column names in the thin client only after query execution.
For example:
ClientConfiguration clientConfig = new ClientConfiguration().setAddresses("127.0.0.1");
try(IgniteClient thinClient = Ignition.startClient(clientConfig)){
SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM T1");
FieldsQueryCursor cursor = thinClient.query(sql);
cursor.getAll();
int count = cursor.getColumnsCount();
System.out.println(count);
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);
}
But if this is the correct behavior I do not know yet, I will try to find out.
--------------------------------
Ilya Kazakov
вт, 3 нояб. 2020 г. в 12:51, Shravya Nethula <sh...@aline-consulting.com>>:
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:1759717cc2dbe2ca0301]
Hyderabad.
Re: How to get column names for a query in Ignite thin client mode
Posted by Shravya Nethula <sh...@aline-consulting.com>.
Hi Alex,
Thank you for the information.
Is there a possibility of getting the datatypes in thick client mode?
Regards,
Shravya Nethula,
BigData Developer,
[cid:0d6f1002-8e08-4cec-a2dd-85d2391ee2f7]
Hyderabad.
________________________________
From: Alex Plehanov <pl...@gmail.com>
Sent: Thursday, November 5, 2020 12:03 PM
To: user@ignite.apache.org <us...@ignite.apache.org>
Cc: Bhargav Kunamneni <bh...@aline-consulting.com>
Subject: Re: How to get column names for a query in Ignite thin client mode
Currently, only field names can be obtained, there is no information about field data types in thin client protocol.
ср, 4 нояб. 2020 г. в 13:58, Shravya Nethula <sh...@aline-consulting.com>>:
Ilya and Alex,
Thank you for information.
Can you please also suggest how to get the datatypes of those columns obtained from the query?
Regards,
Shravya Nethula,
BigData Developer,
[cid:1759717cc2dd11dd2572]
Hyderabad.
________________________________
From: Alex Plehanov <pl...@gmail.com>>
Sent: Tuesday, November 3, 2020 12:13 PM
To: user@ignite.apache.org<ma...@ignite.apache.org> <us...@ignite.apache.org>>
Subject: Re: How to get column names for a query in Ignite thin client mode
Columns information is read by thin-client only after the first data request, so you need to read at least one row to get columns.
вт, 3 нояб. 2020 г. в 09:31, Ilya Kazakov <ka...@gmail.com>>:
Hello, Shravya! It is very interesting! I am trying to reproduce your case, and what I see. I can see column names in the thin client only after query execution.
For example:
ClientConfiguration clientConfig = new ClientConfiguration().setAddresses("127.0.0.1");
try(IgniteClient thinClient = Ignition.startClient(clientConfig)){
SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM T1");
FieldsQueryCursor cursor = thinClient.query(sql);
cursor.getAll();
int count = cursor.getColumnsCount();
System.out.println(count);
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);
}
But if this is the correct behavior I do not know yet, I will try to find out.
--------------------------------
Ilya Kazakov
вт, 3 нояб. 2020 г. в 12:51, Shravya Nethula <sh...@aline-consulting.com>>:
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:1759717cc2dbe2ca0301]
Hyderabad.
Re: How to get column names for a query in Ignite thin client mode
Posted by Alex Plehanov <pl...@gmail.com>.
Currently, only field names can be obtained, there is no information about
field data types in thin client protocol.
ср, 4 нояб. 2020 г. в 13:58, Shravya Nethula <
shravya.nethula@aline-consulting.com>:
> Ilya and Alex,
>
> Thank you for information.
> Can you please also suggest how to get the datatypes of those columns
> obtained from the query?
>
>
> Regards,
>
> Shravya Nethula,
>
> BigData Developer,
>
>
> Hyderabad.
>
>
> ------------------------------
> *From:* Alex Plehanov <pl...@gmail.com>
> *Sent:* Tuesday, November 3, 2020 12:13 PM
> *To:* user@ignite.apache.org <us...@ignite.apache.org>
> *Subject:* Re: How to get column names for a query in Ignite thin client
> mode
>
> Columns information is read by thin-client only after the first data
> request, so you need to read at least one row to get columns.
>
> вт, 3 нояб. 2020 г. в 09:31, Ilya Kazakov <ka...@gmail.com>:
>
> Hello, Shravya! It is very interesting! I am trying to reproduce your
> case, and what I see. I can see column names in the thin client only after
> query execution.
>
> For example:
>
> ClientConfiguration clientConfig = new ClientConfiguration().setAddresses("127.0.0.1");
> try(IgniteClient thinClient = Ignition.startClient(clientConfig)){
> SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM T1");
> FieldsQueryCursor cursor = thinClient.query(sql);
> cursor.getAll();
> int count = cursor.getColumnsCount();
> System.out.println(count);
> 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);
> }
>
>
> But if this is the correct behavior I do not know yet, I will try to find
> out.
>
> --------------------------------
> Ilya Kazakov
>
> вт, 3 нояб. 2020 г. в 12:51, Shravya Nethula <
> shravya.nethula@aline-consulting.com>:
>
> 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,
>
>
> Hyderabad.
>
>
Re: How to get column names for a query in Ignite thin client mode
Posted by Shravya Nethula <sh...@aline-consulting.com>.
Ilya and Alex,
Thank you for information.
Can you please also suggest how to get the datatypes of those columns obtained from the query?
Regards,
Shravya Nethula,
BigData Developer,
[cid:134aaaea-babf-48d0-9084-0e30ff58e8b5]
Hyderabad.
________________________________
From: Alex Plehanov <pl...@gmail.com>
Sent: Tuesday, November 3, 2020 12:13 PM
To: user@ignite.apache.org <us...@ignite.apache.org>
Subject: Re: How to get column names for a query in Ignite thin client mode
Columns information is read by thin-client only after the first data request, so you need to read at least one row to get columns.
вт, 3 нояб. 2020 г. в 09:31, Ilya Kazakov <ka...@gmail.com>>:
Hello, Shravya! It is very interesting! I am trying to reproduce your case, and what I see. I can see column names in the thin client only after query execution.
For example:
ClientConfiguration clientConfig = new ClientConfiguration().setAddresses("127.0.0.1");
try(IgniteClient thinClient = Ignition.startClient(clientConfig)){
SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM T1");
FieldsQueryCursor cursor = thinClient.query(sql);
cursor.getAll();
int count = cursor.getColumnsCount();
System.out.println(count);
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);
}
But if this is the correct behavior I do not know yet, I will try to find out.
--------------------------------
Ilya Kazakov
вт, 3 нояб. 2020 г. в 12:51, Shravya Nethula <sh...@aline-consulting.com>>:
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:1758cc5f3ffbe2ca0301]
Hyderabad.
Re: How to get column names for a query in Ignite thin client mode
Posted by Alex Plehanov <pl...@gmail.com>.
Columns information is read by thin-client only after the first data
request, so you need to read at least one row to get columns.
вт, 3 нояб. 2020 г. в 09:31, Ilya Kazakov <ka...@gmail.com>:
> Hello, Shravya! It is very interesting! I am trying to reproduce your
> case, and what I see. I can see column names in the thin client only after
> query execution.
>
> For example:
>
> ClientConfiguration clientConfig = new ClientConfiguration().setAddresses("127.0.0.1");
> try(IgniteClient thinClient = Ignition.startClient(clientConfig)){
> SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM T1");
> FieldsQueryCursor cursor = thinClient.query(sql);
> cursor.getAll();
> int count = cursor.getColumnsCount();
> System.out.println(count);
> 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);
> }
>
>
> But if this is the correct behavior I do not know yet, I will try to find
> out.
>
> --------------------------------
> Ilya Kazakov
>
> вт, 3 нояб. 2020 г. в 12:51, Shravya Nethula <
> shravya.nethula@aline-consulting.com>:
>
>> 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,
>>
>>
>> Hyderabad.
>>
>>
Re: How to get column names for a query in Ignite thin client mode
Posted by Ilya Kazakov <ka...@gmail.com>.
Hello, Shravya! It is very interesting! I am trying to reproduce your case,
and what I see. I can see column names in the thin client only after query
execution.
For example:
ClientConfiguration clientConfig = new
ClientConfiguration().setAddresses("127.0.0.1");
try(IgniteClient thinClient = Ignition.startClient(clientConfig)){
SqlFieldsQuery sql = new SqlFieldsQuery("SELECT * FROM T1");
FieldsQueryCursor cursor = thinClient.query(sql);
cursor.getAll();
int count = cursor.getColumnsCount();
System.out.println(count);
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);
}
But if this is the correct behavior I do not know yet, I will try to find
out.
--------------------------------
Ilya Kazakov
вт, 3 нояб. 2020 г. в 12:51, Shravya Nethula <
shravya.nethula@aline-consulting.com>:
> 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,
>
>
> Hyderabad.
>
>