From 77e15a24d05411e9d743492d070dc0fd098ae3e2 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 26 Aug 2022 22:17:49 +0200 Subject: [PATCH] Add missing tests for legacy geobase --- programs/server/config.d/legacy_geobase.xml | 1 + .../server/config.d/regions_hierarchy.txt | 1 + programs/server/config.d/regions_names_en.txt | 1 + tests/config/install.sh | 3 + tests/config/legacy_geobase.xml | 4 + tests/config/regions_hierarchy.txt | 12 + tests/config/regions_names_en.txt | 12 + .../02411_legacy_geobase.reference | 286 ++++++++++++++++++ .../0_stateless/02411_legacy_geobase.sql | 12 + 9 files changed, 332 insertions(+) create mode 120000 programs/server/config.d/legacy_geobase.xml create mode 120000 programs/server/config.d/regions_hierarchy.txt create mode 120000 programs/server/config.d/regions_names_en.txt create mode 100644 tests/config/legacy_geobase.xml create mode 100644 tests/config/regions_hierarchy.txt create mode 100644 tests/config/regions_names_en.txt create mode 100644 tests/queries/0_stateless/02411_legacy_geobase.reference create mode 100644 tests/queries/0_stateless/02411_legacy_geobase.sql diff --git a/programs/server/config.d/legacy_geobase.xml b/programs/server/config.d/legacy_geobase.xml new file mode 120000 index 00000000000..500f57b7006 --- /dev/null +++ b/programs/server/config.d/legacy_geobase.xml @@ -0,0 +1 @@ +../../../tests/config/legacy_geobase.xml \ No newline at end of file diff --git a/programs/server/config.d/regions_hierarchy.txt b/programs/server/config.d/regions_hierarchy.txt new file mode 120000 index 00000000000..7b48f46aa94 --- /dev/null +++ b/programs/server/config.d/regions_hierarchy.txt @@ -0,0 +1 @@ +../../../tests/config/regions_hierarchy.txt \ No newline at end of file diff --git a/programs/server/config.d/regions_names_en.txt b/programs/server/config.d/regions_names_en.txt new file mode 120000 index 00000000000..523a1077d9d --- /dev/null +++ b/programs/server/config.d/regions_names_en.txt @@ -0,0 +1 @@ +../../../tests/config/regions_names_en.txt \ No newline at end of file diff --git a/tests/config/install.sh b/tests/config/install.sh index 072787efbb3..bd2f7aa2080 100755 --- a/tests/config/install.sh +++ b/tests/config/install.sh @@ -48,6 +48,7 @@ ln -sf $SRC_PATH/config.d/named_collection.xml $DEST_SERVER_PATH/config.d/ ln -sf $SRC_PATH/config.d/ssl_certs.xml $DEST_SERVER_PATH/config.d/ ln -sf $SRC_PATH/config.d/filesystem_cache_log.xml $DEST_SERVER_PATH/config.d/ ln -sf $SRC_PATH/config.d/session_log.xml $DEST_SERVER_PATH/config.d/ +ln -sf $SRC_PATH/config.d/legacy_geobase.xml $DEST_SERVER_PATH/config.d/ ln -sf $SRC_PATH/users.d/log_queries.xml $DEST_SERVER_PATH/users.d/ ln -sf $SRC_PATH/users.d/readonly.xml $DEST_SERVER_PATH/users.d/ @@ -74,6 +75,8 @@ ln -sf $SRC_PATH/executable_pool_dictionary.xml $DEST_SERVER_PATH/ ln -sf $SRC_PATH/test_function.xml $DEST_SERVER_PATH/ ln -sf $SRC_PATH/top_level_domains $DEST_SERVER_PATH/ +ln -sf $SRC_PATH/regions_hierarchy.txt $DEST_SERVER_PATH/ +ln -sf $SRC_PATH/regions_names_en.txt $DEST_SERVER_PATH/ ln -sf $SRC_PATH/server.key $DEST_SERVER_PATH/ ln -sf $SRC_PATH/server.crt $DEST_SERVER_PATH/ diff --git a/tests/config/legacy_geobase.xml b/tests/config/legacy_geobase.xml new file mode 100644 index 00000000000..3973c55cb86 --- /dev/null +++ b/tests/config/legacy_geobase.xml @@ -0,0 +1,4 @@ + + config.d/regions_hierarchy.txt + config.d/ + diff --git a/tests/config/regions_hierarchy.txt b/tests/config/regions_hierarchy.txt new file mode 100644 index 00000000000..a111da4a825 --- /dev/null +++ b/tests/config/regions_hierarchy.txt @@ -0,0 +1,12 @@ +1 0 0 7000000000 +2 10 3 330000000 +3 2 4 5700000 +4 3 5 330000 +5 4 6 100000 +6 12 3 1500000000 +7 6 4 83000000 +8 7 6 20000000 +9 1 1 1000000000 +10 9 1 600000000 +11 1 1 5300000000 +12 11 1 4700000000 diff --git a/tests/config/regions_names_en.txt b/tests/config/regions_names_en.txt new file mode 100644 index 00000000000..ccd23678289 --- /dev/null +++ b/tests/config/regions_names_en.txt @@ -0,0 +1,12 @@ +1 World +2 USA +3 Colorado +4 Boulder County +5 Boulder +6 China +7 Sichuan +8 Chengdu +9 America +10 North America +11 Eurasia +12 Asia diff --git a/tests/queries/0_stateless/02411_legacy_geobase.reference b/tests/queries/0_stateless/02411_legacy_geobase.reference new file mode 100644 index 00000000000..4fc360d876c --- /dev/null +++ b/tests/queries/0_stateless/02411_legacy_geobase.reference @@ -0,0 +1,286 @@ + +World +USA +Colorado +Boulder County +Boulder +China +Sichuan +Chengdu +America +North America +Eurasia +Asia + 0 +World 0 +USA 0 +Colorado 0 +Boulder County 0 +Boulder 5 Boulder +China 0 +Sichuan 0 +Chengdu 8 Chengdu +America 0 +North America 0 +Eurasia 0 +Asia 0 + 0 +World 0 +USA 0 +Colorado 0 +Boulder County 4 Boulder County +Boulder 4 Boulder County +China 0 +Sichuan 0 +Chengdu 0 +America 0 +North America 0 +Eurasia 0 +Asia 0 + 0 +World 0 +USA 0 +Colorado 3 Colorado +Boulder County 3 Colorado +Boulder 3 Colorado +China 0 +Sichuan 7 Sichuan +Chengdu 7 Sichuan +America 0 +North America 0 +Eurasia 0 +Asia 0 + 0 +World 0 +USA 2 USA +Colorado 2 USA +Boulder County 2 USA +Boulder 2 USA +China 6 China +Sichuan 6 China +Chengdu 6 China +America 0 +North America 0 +Eurasia 0 +Asia 0 + 0 +World 0 +USA 10 North America +Colorado 10 North America +Boulder County 10 North America +Boulder 10 North America +China 12 Asia +Sichuan 12 Asia +Chengdu 12 Asia +America 9 America +North America 10 North America +Eurasia 11 Eurasia +Asia 12 Asia + 0 +World 0 +USA 9 America +Colorado 9 America +Boulder County 9 America +Boulder 9 America +China 11 Eurasia +Sichuan 11 Eurasia +Chengdu 11 Eurasia +America 9 America +North America 9 America +Eurasia 11 Eurasia +Asia 11 Eurasia + 0 +World 4294967295 +USA 330000000 +Colorado 5700000 +Boulder County 330000 +Boulder 100000 +China 1500000000 +Sichuan 83000000 +Chengdu 20000000 +America 1000000000 +North America 600000000 +Eurasia 4294967295 +Asia 4294967295 + is not in + is not in World + is not in USA + is not in Colorado + is not in Boulder County + is not in Boulder + is not in China + is not in Sichuan + is not in Chengdu + is not in America + is not in North America + is not in Eurasia + is not in Asia +World is not in +World is in World +World is not in USA +World is not in Colorado +World is not in Boulder County +World is not in Boulder +World is not in China +World is not in Sichuan +World is not in Chengdu +World is not in America +World is not in North America +World is not in Eurasia +World is not in Asia +USA is not in +USA is in World +USA is in USA +USA is not in Colorado +USA is not in Boulder County +USA is not in Boulder +USA is not in China +USA is not in Sichuan +USA is not in Chengdu +USA is in America +USA is in North America +USA is not in Eurasia +USA is not in Asia +Colorado is not in +Colorado is in World +Colorado is in USA +Colorado is in Colorado +Colorado is not in Boulder County +Colorado is not in Boulder +Colorado is not in China +Colorado is not in Sichuan +Colorado is not in Chengdu +Colorado is in America +Colorado is in North America +Colorado is not in Eurasia +Colorado is not in Asia +Boulder County is not in +Boulder County is in World +Boulder County is in USA +Boulder County is in Colorado +Boulder County is in Boulder County +Boulder County is not in Boulder +Boulder County is not in China +Boulder County is not in Sichuan +Boulder County is not in Chengdu +Boulder County is in America +Boulder County is in North America +Boulder County is not in Eurasia +Boulder County is not in Asia +Boulder is not in +Boulder is in World +Boulder is in USA +Boulder is in Colorado +Boulder is in Boulder County +Boulder is in Boulder +Boulder is not in China +Boulder is not in Sichuan +Boulder is not in Chengdu +Boulder is in America +Boulder is in North America +Boulder is not in Eurasia +Boulder is not in Asia +China is not in +China is in World +China is not in USA +China is not in Colorado +China is not in Boulder County +China is not in Boulder +China is in China +China is not in Sichuan +China is not in Chengdu +China is not in America +China is not in North America +China is in Eurasia +China is in Asia +Sichuan is not in +Sichuan is in World +Sichuan is not in USA +Sichuan is not in Colorado +Sichuan is not in Boulder County +Sichuan is not in Boulder +Sichuan is in China +Sichuan is in Sichuan +Sichuan is not in Chengdu +Sichuan is not in America +Sichuan is not in North America +Sichuan is in Eurasia +Sichuan is in Asia +Chengdu is not in +Chengdu is in World +Chengdu is not in USA +Chengdu is not in Colorado +Chengdu is not in Boulder County +Chengdu is not in Boulder +Chengdu is in China +Chengdu is in Sichuan +Chengdu is in Chengdu +Chengdu is not in America +Chengdu is not in North America +Chengdu is in Eurasia +Chengdu is in Asia +America is not in +America is in World +America is not in USA +America is not in Colorado +America is not in Boulder County +America is not in Boulder +America is not in China +America is not in Sichuan +America is not in Chengdu +America is in America +America is not in North America +America is not in Eurasia +America is not in Asia +North America is not in +North America is in World +North America is not in USA +North America is not in Colorado +North America is not in Boulder County +North America is not in Boulder +North America is not in China +North America is not in Sichuan +North America is not in Chengdu +North America is in America +North America is in North America +North America is not in Eurasia +North America is not in Asia +Eurasia is not in +Eurasia is in World +Eurasia is not in USA +Eurasia is not in Colorado +Eurasia is not in Boulder County +Eurasia is not in Boulder +Eurasia is not in China +Eurasia is not in Sichuan +Eurasia is not in Chengdu +Eurasia is not in America +Eurasia is not in North America +Eurasia is in Eurasia +Eurasia is not in Asia +Asia is not in +Asia is in World +Asia is not in USA +Asia is not in Colorado +Asia is not in Boulder County +Asia is not in Boulder +Asia is not in China +Asia is not in Sichuan +Asia is not in Chengdu +Asia is not in America +Asia is not in North America +Asia is in Eurasia +Asia is in Asia +[] [] +[1] ['World'] +[2,10,9,1] ['USA','North America','America','World'] +[3,2,10,9,1] ['Colorado','USA','North America','America','World'] +[4,3,2,10,9,1] ['Boulder County','Colorado','USA','North America','America','World'] +[5,4,3,2,10,9,1] ['Boulder','Boulder County','Colorado','USA','North America','America','World'] +[6,12,11,1] ['China','Asia','Eurasia','World'] +[7,6,12,11,1] ['Sichuan','China','Asia','Eurasia','World'] +[8,7,6,12,11,1] ['Chengdu','Sichuan','China','Asia','Eurasia','World'] +[9,1] ['America','World'] +[10,9,1] ['North America','America','World'] +[11,1] ['Eurasia','World'] +[12,11,1] ['Asia','Eurasia','World'] diff --git a/tests/queries/0_stateless/02411_legacy_geobase.sql b/tests/queries/0_stateless/02411_legacy_geobase.sql new file mode 100644 index 00000000000..bf34834bbaf --- /dev/null +++ b/tests/queries/0_stateless/02411_legacy_geobase.sql @@ -0,0 +1,12 @@ +SELECT regionToName(number::UInt32, 'en') FROM numbers(13); +SELECT regionToName(number::UInt32, 'xy') FROM numbers(13); -- { serverError 1000 } + +SELECT regionToName(number::UInt32, 'en'), regionToCity(number::UInt32) AS id, regionToName(id, 'en') FROM numbers(13); +SELECT regionToName(number::UInt32, 'en'), regionToArea(number::UInt32) AS id, regionToName(id, 'en') FROM numbers(13); +SELECT regionToName(number::UInt32, 'en'), regionToDistrict(number::UInt32) AS id, regionToName(id, 'en') FROM numbers(13); +SELECT regionToName(number::UInt32, 'en'), regionToCountry(number::UInt32) AS id, regionToName(id, 'en') FROM numbers(13); +SELECT regionToName(number::UInt32, 'en'), regionToContinent(number::UInt32) AS id, regionToName(id, 'en') FROM numbers(13); +SELECT regionToName(number::UInt32, 'en'), regionToTopContinent(number::UInt32) AS id, regionToName(id, 'en') FROM numbers(13); +SELECT regionToName(number::UInt32, 'en'), regionToPopulation(number::UInt32) AS id, regionToName(id, 'en') FROM numbers(13); +SELECT regionToName(n1.number::UInt32, 'en') || (regionIn(n1.number::UInt32, n2.number::UInt32) ? ' is in ' : ' is not in ') || regionToName(n2.number::UInt32, 'en') FROM numbers(13) AS n1 CROSS JOIN numbers(13) AS n2; +SELECT regionHierarchy(number::UInt32) AS arr, arrayMap(id -> regionToName(id, 'en'), arr) FROM numbers(13);