diff --git a/CHANGELOG.md b/CHANGELOG.md index dad3ff8186052aa2b6959711e7a0c98ff5b3c53a..eeb14041c94aacb1451a72405c062bf0e33aa392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ with the `YY.MINOR.MICRO` scheme. - Fix error "Read access to space '_raft_state' is denied" when executing a DML query on global tables +- SQL now supports inferring sharding key from primary key, when + the former is not specified in `create table` clause ### Configuration diff --git a/test/int/test_sql.py b/test/int/test_sql.py index 1df31106c327a00276ce2a920ca6efa942e271f5..8c31661d6aba579e12557bf5d7ee3cde6f86f0e4 100644 --- a/test/int/test_sql.py +++ b/test/int/test_sql.py @@ -1748,6 +1748,23 @@ def test_create_drop_table(cluster: Cluster): assert ddl["row_count"] == 1 cluster.raft_wait_index(i1.raft_get_index()) + # check distribution can be skipped and sharding key + # will be inferred from primary key + ddl = i1.sql( + """ + create table "infer_sk" ("a" string, "b" string, + primary key ("b", "a")) + """ + ) + assert ddl["row_count"] == 1 + data = i1.sql( + """ + select "distribution" from "_pico_table" + where "name" = 'infer_sk' + """ + ) + assert data == [[{"ShardedImplicitly": [["b", "a"], "murmur3", "default"]}]] + with pytest.raises(TarantoolError, match="global spaces can use only memtx engine"): i1.sql( """