ivandasch commented on a change in pull request #18:
URL:
https://github.com/apache/ignite-python-thin-client/pull/18#discussion_r579021584
##########
File path: tests/test_sql.py
##########
@@ -193,6 +198,73 @@ def test_long_multipage_query(client):
client.sql(drop_query)
-def test_sql_not_create_cache(client):
+def test_sql_not_create_cache_with_schema(client):
with pytest.raises(SQLError, match=r".*Cache does not exist.*"):
- client.sql(schema='IS_NOT_EXISTING', query_str='select * from
IsNotExisting')
+ client.sql(schema=None, cache='NOT_EXISTING', query_str='select * from
NotExisting')
+
+
+def test_sql_not_create_cache_with_cache(client):
+ with pytest.raises(SQLError, match=r".*Failed to set schema.*"):
+ client.sql(schema='NOT_EXISTING', query_str='select * from
NotExisting')
+
+
+def test_query_with_cache(client):
+ test_key = 42
+ test_value = 'Lorem ipsum'
+
+ cache_name = test_query_with_cache.__name__.upper()
+ schema_name = f'{cache_name}_schema'.upper()
+ table_name = f'{cache_name}_table'.upper()
+
+ cache = client.create_cache({
+ PROP_NAME: cache_name,
+ PROP_SQL_SCHEMA: schema_name,
+ PROP_CACHE_MODE: CacheMode.PARTITIONED,
+ PROP_QUERY_ENTITIES: [
+ {
+ 'table_name': table_name,
+ 'key_field_name': 'KEY',
+ 'value_field_name': 'VALUE',
+ 'key_type_name': 'java.lang.Long',
+ 'value_type_name': 'java.lang.String',
+ 'query_indexes': [],
+ 'field_name_aliases': [],
+ 'query_fields': [
+ {
+ 'name': 'KEY',
+ 'type_name': 'java.lang.Long',
+ 'is_key_field': True,
+ 'is_notnull_constraint_field': True,
+ },
+ {
+ 'name': 'VALUE',
+ 'type_name': 'java.lang.String',
+ },
+ ],
+ },
+ ],
+ })
+
+ qry = f'select value from {table_name}'
+
+ cache.put(test_key, test_value)
+
+ page = client.sql(qry, schema=schema_name)
Review comment:
```
for param, value in [('schema', schema_name), ('cache', cache), ('cache',
cache.name), ('cache', cache.cache_id)]:
page = client.sql(qry, **{param: value})
received = next(page)[0]
assert test_value == received
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]