diff --git a/.github/composite-actions/build-install-pgaudit-extension/action.yml b/.github/composite-actions/build-install-pgaudit-extension/action.yml index 900da52ff3..e808914c6f 100644 --- a/.github/composite-actions/build-install-pgaudit-extension/action.yml +++ b/.github/composite-actions/build-install-pgaudit-extension/action.yml @@ -23,8 +23,8 @@ runs: echo "everything set" ~/${{ inputs.install_dir }}/bin/pg_ctl -c -D ~/psql/data/ -l logfile restart - sudo PGPASSWORD=12345678 ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user -c "CREATE EXTENSION pgaudit;" - sudo PGPASSWORD=12345678 ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user -c "ALTER SYSTEM SET pgaudit.log = 'all';" + sudo PGPASSWORD=12345678 ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "CREATE EXTENSION pgaudit;" + sudo PGPASSWORD=12345678 ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "ALTER SYSTEM SET pgaudit.log = 'all';" shell: bash \ No newline at end of file diff --git a/.github/composite-actions/dump-restore-util/action.yml b/.github/composite-actions/dump-restore-util/action.yml index f2be167391..5d83d28972 100644 --- a/.github/composite-actions/dump-restore-util/action.yml +++ b/.github/composite-actions/dump-restore-util/action.yml @@ -85,14 +85,14 @@ runs: echo "Starting to dump whole Babelfish physical database" if [[ '${{ inputs.type }}' == 'full' ]];then # Perform the complete dump - $DUMP_RESTORE_UTILS_PATH/pg_dumpall -h localhost --database jdbc_testdb --username jdbc_user --roles-only --quote-all-identifiers --no-role-passwords -f pg_dump_globals.sql > ~/upgrade/error.log - $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --file="pg_dump.archive" --dbname=jdbc_testdb > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dumpall -h localhost --database babelfish_db --username jdbc_user --roles-only --quote-all-identifiers --no-role-passwords -f pg_dump_globals.sql > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --file="pg_dump.archive" --dbname=babelfish_db > ~/upgrade/error.log else # First perform the schema-only dump and then perform the data-only dump to produce a complete dump - $DUMP_RESTORE_UTILS_PATH/pg_dumpall -h localhost --database jdbc_testdb --username jdbc_user --roles-only --quote-all-identifiers --schema-only --no-role-passwords -f pg_dump_globals_so.sql > ~/upgrade/error.log - $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --schema-only --file="pg_dump_so.archive" --dbname=jdbc_testdb > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dumpall -h localhost --database babelfish_db --username jdbc_user --roles-only --quote-all-identifiers --schema-only --no-role-passwords -f pg_dump_globals_so.sql > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --schema-only --file="pg_dump_so.archive" --dbname=babelfish_db > ~/upgrade/error.log - $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --data-only --file="pg_dump_do.archive" --dbname=jdbc_testdb > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --data-only --file="pg_dump_do.archive" --dbname=babelfish_db > ~/upgrade/error.log fi else echo "Starting to dump all the Babelfish logical databases" @@ -102,28 +102,28 @@ runs: pg_has_role(rolname, 'sysadmin', 'member') AS is_sysadmin_member \ FROM sys.babelfish_authid_login_ext \ WHERE rolname NOT IN ('jdbc_user', 'sysadmin', 'bbf_role_admin', 'test@ABC');" - ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user -c "$query" > ~/upgrade/logins_file.txt + ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "$query" > ~/upgrade/logins_file.txt # Get the list of Babelfish user and login mapping in a file query="SELECT u.orig_username, l.orig_loginname, database_name \ FROM sys.babelfish_authid_user_ext u INNER JOIN sys.babelfish_authid_login_ext l \ ON u.login_name = l.rolname WHERE u.login_name != '' ORDER BY orig_username;" - ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user -c "$query" > ~/upgrade/users_file.txt + ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "$query" > ~/upgrade/users_file.txt # Get the list of domain mappings in a file query="SELECT netbios_domain_name, fq_domain_name FROM sys.babelfish_domain_mapping;" - ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user -c "$query" > ~/upgrade/domains_file.txt + ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "$query" > ~/upgrade/domains_file.txt # Get the list of all foreign servers in a file query="SELECT fs.srvname, fs.srvoptions, um.umoptions, so.query_timeout, so.connect_timeout \ FROM pg_foreign_server fs \ INNER JOIN sys.babelfish_server_options so ON fs.srvname = so.servername \ LEFT JOIN pg_user_mappings um ON fs.srvname = um.srvname;" - ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user -c "$query" > ~/upgrade/servers_file.txt + ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "$query" > ~/upgrade/servers_file.txt # Get the list of all the Babelfish logical datababses in a file query="SELECT name FROM sys.babelfish_sysdatabases ORDER BY name DESC;" - ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user -c "$query" > ~/upgrade/databases_file.txt + ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "$query" > ~/upgrade/databases_file.txt # Loop through the list of all the Babelfish logical database and dump them one by one. while IFS= read -r db; do @@ -131,19 +131,19 @@ runs: db_trimmed="$(echo "${db}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" if [[ '${{ inputs.type }}' == 'full' ]];then # Perform the complete dump - $DUMP_RESTORE_UTILS_PATH/pg_dumpall -h localhost --database jdbc_testdb --username jdbc_user --roles-only --quote-all-identifiers --no-role-passwords --bbf-database-name="$db_trimmed" -f pg_dump_globals_"$db_trimmed".sql > ~/upgrade/error.log - $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --bbf-database-name="$db_trimmed" --file=pg_dump_"$db_trimmed".archive --dbname=jdbc_testdb > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dumpall -h localhost --database babelfish_db --username jdbc_user --roles-only --quote-all-identifiers --no-role-passwords --bbf-database-name="$db_trimmed" -f pg_dump_globals_"$db_trimmed".sql > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --bbf-database-name="$db_trimmed" --file=pg_dump_"$db_trimmed".archive --dbname=babelfish_db > ~/upgrade/error.log else # First perform the schema-only dump and then perform the data-only dump to produce a complete dump - $DUMP_RESTORE_UTILS_PATH/pg_dumpall -h localhost --database jdbc_testdb --username jdbc_user --roles-only --quote-all-identifiers --schema-only --no-role-passwords --bbf-database-name="$db_trimmed" -f pg_dump_globals_"$db_trimmed"_so.sql > ~/upgrade/error.log - $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --schema-only --bbf-database-name="$db_trimmed" --file=pg_dump_"$db_trimmed"_so.archive --dbname=jdbc_testdb > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dumpall -h localhost --database babelfish_db --username jdbc_user --roles-only --quote-all-identifiers --schema-only --no-role-passwords --bbf-database-name="$db_trimmed" -f pg_dump_globals_"$db_trimmed"_so.sql > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --schema-only --bbf-database-name="$db_trimmed" --file=pg_dump_"$db_trimmed"_so.archive --dbname=babelfish_db > ~/upgrade/error.log - $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --data-only --bbf-database-name="$db_trimmed" --file=pg_dump_"$db_trimmed"_do.archive --dbname=jdbc_testdb > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user $DUMP_OPTS --quote-all-identifiers --data-only --bbf-database-name="$db_trimmed" --file=pg_dump_"$db_trimmed"_do.archive --dbname=babelfish_db > ~/upgrade/error.log fi done < <(tail -n +3 ~/upgrade/databases_file.txt | head -n -2) # Also dump the objects in PUBLIC schema. - $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user --quote-all-identifiers --schema=public --schema-only --file=pg_dump_public.sql --dbname=jdbc_testdb > ~/upgrade/error_public_schema.log + $DUMP_RESTORE_UTILS_PATH/pg_dump -h localhost --username jdbc_user --quote-all-identifiers --schema=public --schema-only --file=pg_dump_public.sql --dbname=babelfish_db > ~/upgrade/error_public_schema.log fi # Stop old server and start the new. @@ -153,29 +153,29 @@ runs: echo 'Database dump complete.' # Create and initialise Babelfish extensions in the new server to perform restore. - sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -v migration_mode=${{inputs.migration_mode}} -v tsql_port="1433" -f .github/scripts/create_extension.sql + sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -v migration_mode=${{inputs.migration_mode}} -v tsql_port="1433" -f .github/scripts/create_extension.sql if [[ ${{ inputs.database_level }} == false ]];then echo "Starting to restore whole Babelfish physical database" if [[ '${{ inputs.type }}' == 'full' ]];then echo 'Restoring from pg_dumpall' - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_globals.sql > ~/upgrade/error.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_globals.sql > ~/upgrade/error.log echo 'Restoring from pg_dump' if [[ '${{ inputs.dump_format }}' == 'plain' ]];then - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump.archive > ~/upgrade/error.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump.archive > ~/upgrade/error.log else - $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d jdbc_testdb -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump.archive > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d babelfish_db -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump.archive > ~/upgrade/error.log fi else echo 'Restoring from pg_dumpall' - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_globals_so.sql > ~/upgrade/error.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_globals_so.sql > ~/upgrade/error.log echo 'Restoring from pg_dump' if [[ '${{ inputs.dump_format }}' == 'plain' ]];then - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_so.archive > ~/upgrade/error.log - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_do.archive > ~/upgrade/error.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_so.archive > ~/upgrade/error.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_do.archive > ~/upgrade/error.log else - $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d jdbc_testdb -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_so.archive > ~/upgrade/error.log - $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d jdbc_testdb -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_do.archive > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d babelfish_db -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_so.archive > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d babelfish_db -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_do.archive > ~/upgrade/error.log fi fi else @@ -186,29 +186,29 @@ runs: db_trimmed="$(echo -e "${db}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" echo "Restoring $db_trimmed" if [[ '${{ inputs.type }}' == 'full' ]];then - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_globals_"$db_trimmed".sql > ~/upgrade/error.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_globals_"$db_trimmed".sql > ~/upgrade/error.log if [[ '${{ inputs.dump_format }}' == 'plain' ]];then - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_"$db_trimmed".archive > ~/upgrade/error.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_"$db_trimmed".archive > ~/upgrade/error.log else - $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d jdbc_testdb -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_"$db_trimmed".archive > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d babelfish_db -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_"$db_trimmed".archive > ~/upgrade/error.log fi else - sudo PGPASSWORD=12345678 ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_globals_"$db_trimmed"_so.sql > ~/upgrade/error.log + sudo PGPASSWORD=12345678 ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_globals_"$db_trimmed"_so.sql > ~/upgrade/error.log if [[ '${{ inputs.dump_format }}' == 'plain' ]];then - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_"$db_trimmed"_so.archive > ~/upgrade/error.log - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_"$db_trimmed"_do.archive > ~/upgrade/error.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_"$db_trimmed"_so.archive > ~/upgrade/error.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user --single-transaction -f ~/upgrade/dump/pg_dump_"$db_trimmed"_do.archive > ~/upgrade/error.log else - $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d jdbc_testdb -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_"$db_trimmed"_so.archive > ~/upgrade/error.log - $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d jdbc_testdb -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_"$db_trimmed"_do.archive > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d babelfish_db -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_"$db_trimmed"_so.archive > ~/upgrade/error.log + $DUMP_RESTORE_UTILS_PATH/pg_restore -h localhost -d babelfish_db -U jdbc_user --single-transaction ~/upgrade/dump/pg_dump_"$db_trimmed"_do.archive > ~/upgrade/error.log fi fi done < <(tail -n +3 ~/upgrade/databases_file.txt | head -n -2) # Create rds_ad role - sudo PGPASSWORD=12345678 ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user -c "CREATE ROLE rds_ad NOSUPERUSER NOLOGIN NOCREATEROLE INHERIT NOREPLICATION;" + sudo PGPASSWORD=12345678 ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "CREATE ROLE rds_ad NOSUPERUSER NOLOGIN NOCREATEROLE INHERIT NOREPLICATION;" # Create tds_fdw extension - sudo PGPASSWORD=12345678 ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d jdbc_testdb -U jdbc_user -c "CREATE EXTENSION IF NOT EXISTS tds_fdw;" + sudo PGPASSWORD=12345678 ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "CREATE EXTENSION IF NOT EXISTS tds_fdw;" # Re-create windows login [abc\test] # This is the only special role which needs to created before re-creating @@ -319,7 +319,7 @@ runs: done < <(tail -n +3 ~/upgrade/servers_file.txt | head -n -2) # Restore the objects in PUBLIC schema. - sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -h localhost -d jdbc_testdb -U jdbc_user -f ~/upgrade/dump/pg_dump_public.sql &> ~/upgrade/error_public_schema.log + sudo PGPASSWORD=12345678 $DUMP_RESTORE_UTILS_PATH/psql -h localhost -d babelfish_db -U jdbc_user -f ~/upgrade/dump/pg_dump_public.sql &> ~/upgrade/error_public_schema.log fi echo 'Database restore complete.' rm -rf ~/upgrade/dump diff --git a/.github/composite-actions/install-and-run-odbc/action.yml b/.github/composite-actions/install-and-run-odbc/action.yml index 5299bf86a2..174c3aec7e 100644 --- a/.github/composite-actions/install-and-run-odbc/action.yml +++ b/.github/composite-actions/install-and-run-odbc/action.yml @@ -59,6 +59,6 @@ runs: PSQL_BABEL_DB_PORT=5432 \ PSQL_BABEL_DB_USER=jdbc_user \ PSQL_BABEL_DB_PASSWORD=12345678 \ - PSQL_BABEL_DB_NAME=jdbc_testdb \ + PSQL_BABEL_DB_NAME=babelfish_db \ ./build/main shell: bash diff --git a/.github/composite-actions/install-dependencies/action.yml b/.github/composite-actions/install-dependencies/action.yml index e531d9f8db..de0912e518 100644 --- a/.github/composite-actions/install-dependencies/action.yml +++ b/.github/composite-actions/install-dependencies/action.yml @@ -9,7 +9,7 @@ runs: curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list sudo apt-get update --fix-missing -y - sudo apt-get install uuid-dev openjdk-8-jre libicu-dev libxml2-dev openssl libssl-dev python3-dev libossp-uuid-dev libpq-dev cmake pkg-config g++ build-essential bison mssql-tools unixodbc-dev libsybdb5 freetds-dev freetds-common gdal-bin libgdal-dev libgeos-dev gdb libkrb5-dev + sudo apt-get install uuid-dev openjdk-21-jre libicu-dev libxml2-dev openssl libssl-dev python3-dev libossp-uuid-dev libpq-dev cmake pkg-config g++ build-essential bison mssql-tools unixodbc-dev libsybdb5 freetds-dev freetds-common gdal-bin libgdal-dev libgeos-dev gdb libkrb5-dev sudo apt install -y ccache sudo apt-get install lcov sudo /usr/sbin/update-ccache-symlinks diff --git a/.github/composite-actions/install-extensions/action.yml b/.github/composite-actions/install-extensions/action.yml index ab945d9f8e..367606c0fc 100644 --- a/.github/composite-actions/install-extensions/action.yml +++ b/.github/composite-actions/install-extensions/action.yml @@ -67,7 +67,7 @@ runs: fi ~/${{inputs.install_dir}}/bin/pg_ctl -c -D ~/${{inputs.install_dir}}/$DATADIR/ -l logfile start cd ~/work/babelfish_extensions/babelfish_extensions/ - sudo ~/${{inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -p ${{inputs.psql_port}} -v user="jdbc_user" -v db="jdbc_testdb" -v migration_mode=${{inputs.migration_mode}} -v tsql_port=${{inputs.tsql_port}} -v parallel_query_mode=${{inputs.parallel_query_mode}} -f .github/scripts/create_extension.sql + sudo ~/${{inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -p ${{inputs.psql_port}} -v user="jdbc_user" -v db="babelfish_db" -v migration_mode=${{inputs.migration_mode}} -v tsql_port=${{inputs.tsql_port}} -v parallel_query_mode=${{inputs.parallel_query_mode}} -f .github/scripts/create_extension.sql ~/${{inputs.install_dir}}/bin/pg_ctl -c -D ~/${{inputs.install_dir}}/$DATADIR/ -l logfile restart sqlcmd -S localhost,${{inputs.tsql_port}} -U "jdbc_user" -P 12345678 -Q "SELECT @@version GO" shell: bash diff --git a/.github/composite-actions/minor-version-upgrade-util/action.yml b/.github/composite-actions/minor-version-upgrade-util/action.yml index 7671436fc5..00a4d5e79d 100644 --- a/.github/composite-actions/minor-version-upgrade-util/action.yml +++ b/.github/composite-actions/minor-version-upgrade-util/action.yml @@ -56,10 +56,10 @@ runs: ulimit -c unlimited cd ~ ~/${{ inputs.install_dir }}/bin/pg_ctl -c -D ~/${{ inputs.install_dir }}/data/ -l logfile restart - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "\dx" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER EXTENSION "babelfishpg_common" UPDATE;" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER EXTENSION "babelfishpg_tsql" UPDATE;" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "\dx" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "\dx" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER EXTENSION "babelfishpg_common" UPDATE;" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER EXTENSION "babelfishpg_tsql" UPDATE;" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "\dx" sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT @@version GO" shell: bash @@ -69,8 +69,8 @@ runs: id: change-migration-mode if: always() && inputs.is_final_ver == 'true' run: | - sudo ~/${{ inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db';" - sudo ~/${{ inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "SELECT pg_reload_conf();" + sudo ~/${{ inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db';" + sudo ~/${{ inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "SELECT pg_reload_conf();" shell: bash - name: Run JDBC Verify Tests diff --git a/.github/composite-actions/run-pg-upgrade/action.yml b/.github/composite-actions/run-pg-upgrade/action.yml index 98666d7d5c..73e5ceec6a 100644 --- a/.github/composite-actions/run-pg-upgrade/action.yml +++ b/.github/composite-actions/run-pg-upgrade/action.yml @@ -37,14 +37,14 @@ runs: echo 'Updating babelfish extensions...' cd ~/work/babelfish_extensions/babelfish_extensions/ ~/${{ inputs.pg_new_dir }}/bin/pg_ctl -c -D ~/${{ inputs.pg_new_dir }}/data -l ~/${{ inputs.pg_new_dir }}/data/logfile start - sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER EXTENSION babelfishpg_common UPDATE;" - sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER EXTENSION babelfishpg_tsql UPDATE;" - sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "\dx" + sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER EXTENSION babelfishpg_common UPDATE;" + sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER EXTENSION babelfishpg_tsql UPDATE;" + sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "\dx" echo 'Reset bbf database settings...' - sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb';" - sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = '${{inputs.migration_mode}}';" - sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER SYSTEM SET track_functions = 'pl';" - sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "SELECT pg_reload_conf();" + sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'babelfish_db';" + sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = '${{inputs.migration_mode}}';" + sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER SYSTEM SET track_functions = 'pl';" + sudo ~/${{ inputs.pg_new_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "SELECT pg_reload_conf();" if [[ ${{ inputs.server_collation_name }} != "default" ]]; then sudo echo "babelfishpg_tsql.server_collation_name = '${{ inputs.server_collation_name }}'" >> ~/${{ inputs.pg_new_dir }}/data/postgresql.conf ~/${{ inputs.pg_new_dir }}/bin/pg_ctl -c -D ~/${{ inputs.pg_new_dir }}/data/ -l ~/${{ inputs.pg_new_dir }}/data/logfile restart diff --git a/.github/composite-actions/run-verify-tests/action.yml b/.github/composite-actions/run-verify-tests/action.yml index be4596bb17..3db6a7de33 100644 --- a/.github/composite-actions/run-verify-tests/action.yml +++ b/.github/composite-actions/run-verify-tests/action.yml @@ -41,6 +41,7 @@ runs: touch dummy_schedule echo "all" > dummy_schedule export scheduleFile=dummy_schedule + export physicalDatabaseName=babelfish_db export isUpgradeTestMode=false if [[ ${{ inputs.server_collation_name }} != "default" ]]; then export serverCollationName=${{ inputs.server_collation_name }} @@ -81,5 +82,5 @@ runs: id: cleanup if: always() && steps.jdbc-verify-tests.outcome == 'success' && inputs.is_final_ver == 'true' run: | - sudo ~/${{ inputs.pg_new_dir }}/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/${{ inputs.pg_new_dir }}/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql shell: bash \ No newline at end of file diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index d4e28eb406..abaed4feee 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -143,16 +143,16 @@ runs: fi ~/${{ inputs.install_dir }}/bin/pg_ctl -c -D ~/${{ inputs.install_dir }}/data/ -l logfile restart sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -c "CREATE USER jdbc_user WITH SUPERUSER CREATEDB CREATEROLE PASSWORD '12345678' INHERIT;" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -c "DROP DATABASE IF EXISTS jdbc_testdb;" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -c "CREATE DATABASE jdbc_testdb OWNER jdbc_user;" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "set allow_system_table_mods = on;" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "CREATE EXTENSION "babelfishpg_tds" CASCADE;" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "GRANT ALL ON SCHEMA sys to jdbc_user;" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER USER jdbc_user CREATEDB;" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb';" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "SELECT pg_reload_conf();" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "CALL sys.initialize_babelfish('jdbc_user');" - sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "\dx" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -c "DROP DATABASE IF EXISTS babelfish_db;" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -c "CREATE DATABASE babelfish_db OWNER jdbc_user;" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "set allow_system_table_mods = on;" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "CREATE EXTENSION "babelfishpg_tds" CASCADE;" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "GRANT ALL ON SCHEMA sys to jdbc_user;" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER USER jdbc_user CREATEDB;" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'babelfish_db';" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "SELECT pg_reload_conf();" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "CALL sys.initialize_babelfish('jdbc_user');" + sudo ~/${{ inputs.install_dir }}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "\dx" sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT @@version GO" shell: bash @@ -160,8 +160,8 @@ runs: id: change-migration-mode if: ${{ inputs.migration_mode == 'multi-db' }} && always() run: | - sudo ~/${{ inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db';" - sudo ~/${{ inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "SELECT pg_reload_conf();" + sudo ~/${{ inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db';" + sudo ~/${{ inputs.install_dir}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "SELECT pg_reload_conf();" shell: bash - if: ${{ inputs.extension_branch != 'latest' && inputs.dump_restore == 'true' }} @@ -182,6 +182,7 @@ runs: cd test/JDBC/ echo "all" > dummy_schedule export scheduleFile=dummy_schedule + export physicalDatabaseName=babelfish_db if [[ ${{ inputs.server_collation_name }} != "default" ]]; then export serverCollationName=${{ inputs.server_collation_name }} fi @@ -245,7 +246,7 @@ runs: provider="PostgreSQL Unicode" \ fileGenerator_URL=localhost \ fileGenerator_port=5432 \ - fileGenerator_databaseName=jdbc_testdb \ + fileGenerator_databaseName=babelfish_db \ fileGenerator_user=jdbc_user \ fileGenerator_password=12345678 \ LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/odbc/ \ diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 563911493d..48f11a54a2 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -81,8 +81,8 @@ jobs: id: re-install-extensions if: always() && steps.install-extensions.outcome == 'success' run: | - sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql - sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -v migration_mode="multi-db" -v tsql_port=1433 -v parallel_query_mode=false -f .github/scripts/create_extension.sql + sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -v migration_mode="multi-db" -v tsql_port=1433 -v parallel_query_mode=false -f .github/scripts/create_extension.sql sqlcmd -S localhost -U "jdbc_user" -P 12345678 -Q "SELECT @@version GO" - name: Run Python Tests diff --git a/.github/workflows/jdbc-tests-db-collation.yml b/.github/workflows/jdbc-tests-db-collation.yml index c3082fdc89..843a615be1 100644 --- a/.github/workflows/jdbc-tests-db-collation.yml +++ b/.github/workflows/jdbc-tests-db-collation.yml @@ -61,8 +61,8 @@ jobs: export PATH=/opt/mssql-tools/bin:$PATH export PATH=~/${{env.INSTALL_DIR}}/bin:$PATH export PG_SRC=~/work/babelfish_extensions/postgresql_modified_for_babelfish - sudo ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "update sys.babelfish_sysdatabases set default_collation = '${{env.DATABASE_COLLATION_NAME}}' where name = 'master';" - sudo ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "select default_collation from sys.babelfish_sysdatabases where name = 'master';" + sudo ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "update sys.babelfish_sysdatabases set default_collation = '${{env.DATABASE_COLLATION_NAME}}' where name = 'master';" + sudo ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "select default_collation from sys.babelfish_sysdatabases where name = 'master';" cd test/JDBC/ export isdbCollationMode=true mvn -B -ntp test @@ -81,8 +81,8 @@ jobs: id: setup-pub-sub if: always() && steps.start-secondary.outcome == 'success' run: | - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "CREATE PUBLICATION my_pub;" - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=jdbc_testdb password=12345678' PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "CREATE PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=babelfish_db password=12345678' PUBLICATION my_pub;" - name: Run Replication Tests id: replication @@ -91,8 +91,8 @@ jobs: run: | export PATH=~/${{env.INSTALL_DIR}}/bin:$PATH export PG_SRC=~/work/babelfish_extensions/postgresql_modified_for_babelfish - sudo ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -p 5433 -c "update sys.babelfish_sysdatabases set default_collation = '${{env.DATABASE_COLLATION_NAME}}' where name = 'master';" - sudo ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -p 5433 -c "select default_collation from sys.babelfish_sysdatabases where name = 'master';" + sudo ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -p 5433 -c "update sys.babelfish_sysdatabases set default_collation = '${{env.DATABASE_COLLATION_NAME}}' where name = 'master';" + sudo ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -p 5433 -c "select default_collation from sys.babelfish_sysdatabases where name = 'master';" cd test/JDBC/ export isdbCollationMode=true export inputFilesPath=replication @@ -103,7 +103,7 @@ jobs: id: cleanup if: always() && steps.replication.outcome == 'success' run: | - sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql - name: Upload Log if: always() && (steps.jdbc.outcome == 'failure' || steps.replication.outcome == 'failure') diff --git a/.github/workflows/jdbc-tests-pgaudit-enable.yml b/.github/workflows/jdbc-tests-pgaudit-enable.yml index e8e4f7120b..6df859c34c 100644 --- a/.github/workflows/jdbc-tests-pgaudit-enable.yml +++ b/.github/workflows/jdbc-tests-pgaudit-enable.yml @@ -99,8 +99,8 @@ jobs: id: setup-pub-sub if: always() && steps.start-secondary.outcome == 'success' run: | - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "CREATE PUBLICATION my_pub;" - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=jdbc_testdb password=12345678' PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "CREATE PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=babelfish_db password=12345678' PUBLICATION my_pub;" - name: Run Replication Tests id: replication @@ -114,7 +114,7 @@ jobs: id: cleanup if: always() && steps.replication.outcome == 'success' run: | - sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql - name: Upload Log if: always() && (steps.jdbc.outcome == 'failure' || steps.replication.outcome == 'failure') diff --git a/.github/workflows/jdbc-tests-single-db-mode.yml b/.github/workflows/jdbc-tests-single-db-mode.yml index fdc2dc127a..8f470d66b5 100644 --- a/.github/workflows/jdbc-tests-single-db-mode.yml +++ b/.github/workflows/jdbc-tests-single-db-mode.yml @@ -75,8 +75,8 @@ jobs: id: setup-pub-sub if: always() && steps.start-secondary.outcome == 'success' run: | - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "CREATE PUBLICATION my_pub;" - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=jdbc_testdb password=12345678' PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "CREATE PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=babelfish_db password=12345678' PUBLICATION my_pub;" - name: Run Replication Tests id: replication @@ -91,7 +91,7 @@ jobs: id: cleanup if: always() && steps.replication.outcome == 'success' run: | - sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql - name: Upload Log if: always() && (steps.jdbc.outcome == 'failure' || steps.replication.outcome == 'failure') diff --git a/.github/workflows/jdbc-tests-with-non-default-server-collation.yml b/.github/workflows/jdbc-tests-with-non-default-server-collation.yml index 5ee0a0325e..ab266633ef 100644 --- a/.github/workflows/jdbc-tests-with-non-default-server-collation.yml +++ b/.github/workflows/jdbc-tests-with-non-default-server-collation.yml @@ -82,8 +82,8 @@ jobs: id: setup-pub-sub if: always() && steps.start-secondary.outcome == 'success' run: | - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "CREATE PUBLICATION my_pub;" - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=jdbc_testdb password=12345678' PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "CREATE PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=babelfish_db password=12345678' PUBLICATION my_pub;" - name: Run Replication Tests id: replication @@ -97,7 +97,7 @@ jobs: id: cleanup if: always() && steps.replication.outcome == 'success' run: | - sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql - name: Upload Log if: always() && (steps.jdbc.outcome == 'failure' || steps.replication.outcome == 'failure') diff --git a/.github/workflows/jdbc-tests-with-parallel-query.yml b/.github/workflows/jdbc-tests-with-parallel-query.yml index 390f2f0246..4fea052296 100644 --- a/.github/workflows/jdbc-tests-with-parallel-query.yml +++ b/.github/workflows/jdbc-tests-with-parallel-query.yml @@ -70,7 +70,7 @@ jobs: id: cleanup if: always() && steps.install-extensions.outcome == 'success' run: | - sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql - name: Upload Log if: always() && steps.jdbc.outcome == 'failure' diff --git a/.github/workflows/jdbc-tests.yml b/.github/workflows/jdbc-tests.yml index 53a83c2c66..77e71dd0cb 100644 --- a/.github/workflows/jdbc-tests.yml +++ b/.github/workflows/jdbc-tests.yml @@ -74,8 +74,8 @@ jobs: id: setup-pub-sub if: always() && steps.start-secondary.outcome == 'success' run: | - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "CREATE PUBLICATION my_pub;" - ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=jdbc_testdb password=12345678' PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "CREATE PUBLICATION my_pub;" + ~/${{env.INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -p 5433 -c "CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 user=jdbc_user dbname=babelfish_db password=12345678' PUBLICATION my_pub;" - name: Run Replication Tests id: replication @@ -89,7 +89,7 @@ jobs: id: cleanup if: always() && steps.replication.outcome == 'success' run: | - sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql - name: Upload Log if: always() && (steps.jdbc.outcome == 'failure' || steps.replication.outcome == 'failure') diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index 5b0c21092d..01870ad468 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -124,7 +124,7 @@ jobs: } > pg_hba.conf ~/${{env.OLD_INSTALL_DIR}}/bin/pg_ctl -c -D ~/${{env.OLD_INSTALL_DIR}}/data -l ~/${{env.OLD_INSTALL_DIR}}/data/logfile restart cd ~/work/babelfish_extensions/babelfish_extensions/ - sudo ~/${{env.OLD_INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -v migration_mode="multi-db" -v tsql_port="1433" -f .github/scripts/create_extension.sql + sudo ~/${{env.OLD_INSTALL_DIR}}/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -v migration_mode="multi-db" -v tsql_port="1433" -f .github/scripts/create_extension.sql sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT @@version GO" shell: bash diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index 4b2ac76648..c317011f04 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -106,12 +106,12 @@ jobs: sudo make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config install shell: bash + - uses: actions/checkout@v2 + - name: Install extensions id: install-extensions-older if: always() && steps.build-tds_fdw-extension.outcome == 'success' uses: ./.github/composite-actions/install-extensions - - - uses: actions/checkout@v2 - name: Build and run tests for Postgres engine using latest engine id: build-modified-postgres-newer @@ -139,12 +139,12 @@ jobs: ulimit -c unlimited cd ~ ~/psql/bin/pg_ctl -c -D ~/psql/data/ -l logfile restart - sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "\dx" - sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER EXTENSION "babelfishpg_common" UPDATE; ALTER EXTENSION "babelfishpg_tsql" UPDATE;" - sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER SYSTEM SET track_functions = 'pl';" - sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db';" - sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "SELECT pg_reload_conf();" - sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -c "\dx" + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "\dx" + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER EXTENSION "babelfishpg_common" UPDATE; ALTER EXTENSION "babelfishpg_tsql" UPDATE;" + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER SYSTEM SET track_functions = 'pl';" + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db';" + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "SELECT pg_reload_conf();" + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -c "\dx" sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT @@version GO" - name: Run JDBC Tests diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index cc9f9930ac..94168fe96a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -50,7 +50,7 @@ jobs: if: always() && steps.build-babelfishpg_unit.outcome == 'success' timeout-minutes: 60 run: | - sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d jdbc_testdb -U runner -f .github/scripts/unit_tests.sql > >(tee ~/psql/output.out) 2>&1 + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d babelfish_db -U runner -f .github/scripts/unit_tests.sql > >(tee ~/psql/output.out) 2>&1 count=$(awk -F '|' '$2 ~ /fail/' ~/psql/output.out | wc -l) if [ "$count" -gt 0 ]; then echo "Tests failed: $count" diff --git a/INSTALLING.md.tmpl b/INSTALLING.md.tmpl index c8e1c21792..422993f595 100644 --- a/INSTALLING.md.tmpl +++ b/INSTALLING.md.tmpl @@ -29,7 +29,7 @@ sudo apt-get update && sudo apt install -y --no-install-recommends \ cmake lld apt-utils libossp-uuid-dev gnulib bison \ xsltproc icu-devtools libicu66 \ libicu-dev gawk \ - curl openjdk-8-jre openssl \ + curl openjdk-21-jre openssl \ g++ libssl-dev python-dev libpq-dev \ pkg-config libutfcpp-dev \ gnupg unixodbc-dev net-tools unzip diff --git a/contrib/README.md b/contrib/README.md index a120e4c388..28365a798a 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -27,7 +27,7 @@ The following build instructions comply with Ubuntu 20.04 and Amazon Linux 2 env You'll also need to install `gcc`, `gcc-c++`, `java` and `bison`. ``` - sudo apt-get install uuid-dev openjdk-8-jre \ + sudo apt-get install uuid-dev openjdk-21-jre \ libicu-dev libxml2-dev openssl libssl-dev python-dev \ libossp-uuid-dev libpq-dev pkg-config g++ build-essential bison ``` diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c index a1ab6b92d3..ae2c2e2207 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsresponse.c @@ -1769,6 +1769,8 @@ PrepareRowDescription(TupleDesc typeinfo, PlannedStmt *plannedstmt, List *target /* * Get the IO function info from our type cache */ + if (atttypmod == TSQLMaxTypmod) + atttypmod = -1; finfo = TdsLookupTypeFunctionsByOid(atttypid, &atttypmod); /* atttypid = getBaseTypeAndTypmod(atttypid, &atttypmod); */ #if 0 diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsrpc.c b/contrib/babelfishpg_tds/src/backend/tds/tdsrpc.c index 13e2fefe4a..a55d38342a 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsrpc.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsrpc.c @@ -1587,7 +1587,7 @@ ReadParameters(TDSRequestSP request, uint64_t offset, StringInfo message, int *p * Sets the col metadata and also the corresponding row * data. */ - SetColMetadataForTvp(temp, message, &offset); + SetColMetadataForTvp(temp, message, &offset, request->name.data); } break; case TDS_TYPE_BINARY: diff --git a/contrib/babelfishpg_tds/src/include/tds_request.h b/contrib/babelfishpg_tds/src/include/tds_request.h index f3adbf418d..77485916a9 100644 --- a/contrib/babelfishpg_tds/src/include/tds_request.h +++ b/contrib/babelfishpg_tds/src/include/tds_request.h @@ -24,6 +24,7 @@ #include "src/include/tds_typeio.h" #include "src/collation.h" + /* Different TDS request types returned by GetTDSRequest() */ typedef enum TDSRequestType { @@ -498,16 +499,16 @@ SetTvpRowData(ParameterToken temp, const StringInfo message, uint64_t *offset) } static inline void -SetColMetadataForTvp(ParameterToken temp, const StringInfo message, uint64_t *offset) +SetColMetadataForTvp(ParameterToken temp, const StringInfo message, uint64_t *offset, char *proc_name) { - uint8_t len; - uint16 colCount; - uint16 isTvpNull; - char *tempString; - int i = 0; - char *messageData = message->data; - StringInfo tempStringInfo = palloc(sizeof(StringInfoData)); - uint32_t collation; + uint8_t len; + uint16 colCount; + uint16 isTvpNull; + char *tempString; + int i = 0; + char *messageData = message->data; + StringInfo tempStringInfo = palloc(sizeof(StringInfoData)); + uint32_t collation; /* Database-Name.Schema-Name.TableType-Name */ for (; i < 3; i++) @@ -536,21 +537,34 @@ SetColMetadataForTvp(ParameterToken temp, const StringInfo message, uint64_t *of if (i == 1) temp->tvpInfo->tvpTypeSchemaName = tempStringInfo->data; else + { temp->tvpInfo->tvpTypeName = tempStringInfo->data; - + temp->tvpInfo->tableName = tempStringInfo->data; + } } else if (i == 2) { - /* Throw error if TabelType-Name is not provided */ - ereport(ERROR, - (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. " - "Table-valued parameter %d, to a parameterized string has no table type defined.", - temp->paramOrdinal + 1))); + char *tvp_type_name; + char *tvp_type_schema_name; + /* + * Fetch the TVP typeName and schemaName from catalog search + * based on object name and argument name. + */ + pltsql_plugin_handler_ptr->get_tvp_typename_typeschemaname(proc_name, + temp->paramMeta.colName.data, + &tvp_type_name, + &tvp_type_schema_name); + temp->len += strlen(tvp_type_schema_name); + temp->tvpInfo->tvpTypeSchemaName = pstrdup(tvp_type_schema_name); + + pfree(tvp_type_schema_name); + + temp->len += strlen(tvp_type_name); + temp->tvpInfo->tvpTypeName = tvp_type_name; + temp->tvpInfo->tableName = tvp_type_name; } } - temp->tvpInfo->tableName = tempStringInfo->data; i = 0; memcpy(&isTvpNull, &messageData[*offset], sizeof(uint16)); diff --git a/contrib/babelfishpg_tsql/runtime/functions.c b/contrib/babelfishpg_tsql/runtime/functions.c index f30a575037..8842187dff 100644 --- a/contrib/babelfishpg_tsql/runtime/functions.c +++ b/contrib/babelfishpg_tsql/runtime/functions.c @@ -373,7 +373,6 @@ datepart_internal(char* field, Timestamp timestamp, float8 df_tz, bool general_i Timestamp tsql_first_day, first_day; struct pg_tm tt1, *tm = &tt1; uint first_week_end, year, month, day, res = 0, day_of_year; /* for Zeller's Congruence */ - int tz1; /* * This block is used when the second argument in datepart is not a @@ -396,7 +395,7 @@ datepart_internal(char* field, Timestamp timestamp, float8 df_tz, bool general_i } /* Gets the date time related fields back from timestamp into struct tm pointer */ - if (timestamp2tm(timestamp, &tz1, tm, &fsec1, NULL, NULL) != 0) + if (timestamp2tm(timestamp, NULL, tm, &fsec1, NULL, NULL) != 0) { ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), @@ -2134,7 +2133,6 @@ object_id(PG_FUNCTION_ARGS) char *physical_schema_name; char *input; char *object_type = NULL; - char **splited_object_name; Oid schema_oid; Oid user_id = GetUserId(); Oid result = InvalidOid; @@ -2174,31 +2172,13 @@ object_id(PG_FUNCTION_ARGS) (errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH), errmsg("input value is too long for object name"))); - /* resolve the three part name */ - splited_object_name = split_object_name(input); - db_name = splited_object_name[1]; - schema_name = splited_object_name[2]; - object_name = splited_object_name[3]; - - /* downcase identifier if needed */ - if (pltsql_case_insensitive_identifiers) - { - db_name = downcase_identifier(db_name, strlen(db_name), false, false); - schema_name = downcase_identifier(schema_name, strlen(schema_name), false, false); - object_name = downcase_identifier(object_name, strlen(object_name), false, false); - for (int j = 0; j < 4; j++) - pfree(splited_object_name[j]); - } - else - pfree(splited_object_name[0]); + /* + * Split the input string, downcase and truncate if needed + * and return the db_name, schema_name and object_name. + */ + downcase_truncate_split_object_name(input, NULL, &db_name, &schema_name, &object_name); pfree(input); - pfree(splited_object_name); - - /* truncate identifiers if needed */ - truncate_tsql_identifier(db_name); - truncate_tsql_identifier(schema_name); - truncate_tsql_identifier(object_name); if (!strcmp(db_name, "")) db_name = get_cur_db_name(); @@ -2616,7 +2596,6 @@ type_id(PG_FUNCTION_ARGS) *object_name; char *physical_schema_name; char *input; - char **splitted_object_name; Oid schema_oid = InvalidOid; Oid user_id = GetUserId(); Oid result = InvalidOid; @@ -2641,40 +2620,20 @@ type_id(PG_FUNCTION_ARGS) (errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH), errmsg("input value is too long for object name"))); - /* resolve the two part name */ - splitted_object_name = split_object_name(input); + /* + * Split the input string, downcase and truncate if needed + * and return the db_name, schema_name and object_name. + */ + downcase_truncate_split_object_name(input, NULL, &db_name, &schema_name, &object_name); + + pfree(input); + /* If three part name(db_name also included in input) then return null */ - if(pg_mbstrlen(splitted_object_name[1]) != 0) + if(pg_mbstrlen(db_name) != 0) { - pfree(input); - for (int j = 0; j < 4; j++) - pfree(splitted_object_name[j]); - pfree(splitted_object_name); PG_RETURN_NULL(); } db_name = get_cur_db_name(); - schema_name = splitted_object_name[2]; - object_name = splitted_object_name[3]; - - /* downcase identifier if needed */ - if (pltsql_case_insensitive_identifiers) - { - db_name = downcase_identifier(db_name, strlen(db_name), false, false); - schema_name = downcase_identifier(schema_name, strlen(schema_name), false, false); - object_name = downcase_identifier(object_name, strlen(object_name), false, false); - for (int k = 0; k < 4; k++) - pfree(splitted_object_name[k]); - } - else - pfree(splitted_object_name[0]); - - pfree(input); - pfree(splitted_object_name); - - /* truncate identifiers if needed */ - truncate_tsql_identifier(db_name); - truncate_tsql_identifier(schema_name); - truncate_tsql_identifier(object_name); if (!strcmp(schema_name, "")) { diff --git a/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-epilogue.y.c b/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-epilogue.y.c index fd335593d3..1fe565df87 100644 --- a/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-epilogue.y.c +++ b/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-epilogue.y.c @@ -573,7 +573,6 @@ createOpenJsonWithColDef(char *elemName, TypeName *elemType) TypeName * setCharTypmodForOpenjson(TypeName *t) { - int curTMod = getElemTypMod(t); List *tmods = (List *) t->typmods; if (tmods == NULL) @@ -582,13 +581,6 @@ setCharTypmodForOpenjson(TypeName *t) t->typmods = list_make1(makeIntConst(1, -1)); return t; } - else if (curTMod == TSQLMaxTypmod) - { - /* TSQLMaxTypmod is represented as -8000 so we need to change to */ - /* the actual max value of 4000 */ - t->typmods = list_make1(makeIntConst(4000, -1)); - return t; - } else { return t; diff --git a/contrib/babelfishpg_tsql/src/catalog.c b/contrib/babelfishpg_tsql/src/catalog.c index 095b7788d4..aa22cd5f70 100644 --- a/contrib/babelfishpg_tsql/src/catalog.c +++ b/contrib/babelfishpg_tsql/src/catalog.c @@ -14,6 +14,7 @@ #include "catalog/pg_proc.h" #include "catalog/pg_foreign_server.h" #include "catalog/namespace.h" +#include "catalog/pg_type.h" #include "commands/extension.h" #include "commands/schemacmds.h" #include "commands/user.h" @@ -6135,3 +6136,154 @@ alter_default_privilege_on_schema(PG_FUNCTION_ARGS) table_close(db_rel, AccessShareLock); PG_RETURN_INT32(0); } + +/* + * get_proc_namespace_oid: + * Find namespace oid of a procedure based on proc name. + */ +static Oid +get_proc_namespace_oid(char **proc_name, char *curr_db) +{ + char *physical_sch_name; + char *db_name; + char *schema_name; + char *object_name; + Oid obj_schema_oid = InvalidOid; + + if (*proc_name == NULL) + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("procedure name cannot be NULL"))); + + /* + * Split the proc name, downcase and truncate if needed + * and return the db_name, schema_name and object_name. + */ + downcase_truncate_split_object_name(*proc_name, NULL, &db_name, &schema_name, &object_name); + *proc_name = object_name; + + if (!strcmp(db_name, "")) + db_name = curr_db; + + if (!strcmp(schema_name, "")) + { + /* Find the default schema for current user. */ + char *user = get_user_for_database(db_name); + schema_name = get_authid_user_ext_schema_name((const char *) db_name, (const char *) user); + } + + /* Get physical schema name from logical schema name. */ + physical_sch_name = get_physical_schema_name(db_name, schema_name); + /* Get namespace oid from physical schema name. */ + obj_schema_oid = get_namespace_oid(physical_sch_name, false); + + pfree(db_name); + pfree(schema_name); + pfree(physical_sch_name); + + return obj_schema_oid; +} + +/* + * get_proargtypes_oid: + * Given a procedure name, namespace, user ID, and target argument name + * return the OID of the argument's type in the procedure. + * + * Returns InvalidOid if no matching procedure argument is found. + */ +static Oid +get_proargtypes_oid(char *proname, Oid pronamespace, Oid user_id, char *targeted_arg_name) +{ + HeapTuple tuple; + CatCList *catlist; + Oid matched_type = InvalidOid; + + /* Downcase and truncate identifier if needed. */ + targeted_arg_name = downcase_truncate_identifier(targeted_arg_name, strlen(targeted_arg_name), true); + + /* First search in pg_proc by name. */ + catlist = SearchSysCacheList1(PROCNAMEARGSNSP, CStringGetDatum(proname)); + + for (int i = 0; i < catlist->n_members; i++) + { + Form_pg_proc procform; + + tuple = &catlist->members[i]->tuple; + procform = (Form_pg_proc) GETSTRUCT(tuple); + + /* Then consider only procs in specified namespace. */ + if (procform->pronamespace == pronamespace && + object_aclcheck(ProcedureRelationId, procform->oid, user_id, ACL_EXECUTE) == ACLCHECK_OK) + { + /* Get the list of proargames and corresponding proargtypes oids. */ + char **proargnames = fetch_func_input_arg_names(tuple); + Oid *proargtypes = procform->proargtypes.values; + + /* Find the typeoid corresponding to target TVP argument. */ + for (int j = 0; j < procform->pronargs; j++) + { + if (strcmp(proargnames[j], targeted_arg_name) == 0) + { + matched_type = proargtypes[j]; + break; + } + } + } + } + ReleaseSysCacheList(catlist); + if (matched_type == InvalidOid) + { + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_FUNCTION), + errmsg("No procedure found with name \"%s\" that has an argument named \"%s\"", + proname, targeted_arg_name))); + } + return matched_type; +} + +/* + * get_tvp_typename_typeschemaname: + * Retrieves the type name and schema name of a Table-Valued Parameter (TVP) + * for a given stored procedure and argument name. + */ +void +get_tvp_typename_typeschemaname(char *proc_name, char *target_arg_name, char **tvp_type_name, char **tvp_type_schema_name) +{ + bool xactStarted = IsTransactionOrTransactionBlock(); + Oid tvp_proargtype = InvalidOid; + Oid user_id = InvalidOid; + Oid obj_schema_oid = InvalidOid; + HeapTuple tuple; + char *typnamespace; + char *curr_db; + MemoryContext oldContext; + + if (!xactStarted) + StartTransactionCommand(); + user_id = GetUserId(); + curr_db = get_cur_db_name(); + + /* Get procedure namespaceid. */ + obj_schema_oid = get_proc_namespace_oid(&proc_name, curr_db); + + /* Fetch proargtype value of our targeted variable. */ + tvp_proargtype = get_proargtypes_oid(proc_name, obj_schema_oid, user_id, target_arg_name); + + /* Search in pg_type by object_id and fetch tvpTypeName and tvpTypeSchemaName. */ + tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(tvp_proargtype)); + /* Check if user have right permission on object. */ + if (HeapTupleIsValid(tuple) && object_aclcheck(TypeRelationId, tvp_proargtype, user_id, ACL_USAGE) == ACLCHECK_OK) + { + Form_pg_type pg_type = (Form_pg_type) GETSTRUCT(tuple); + *tvp_type_name = NameStr(pg_type->typname); + typnamespace = get_namespace_name(pg_type->typnamespace); + + oldContext = MemoryContextSwitchTo(TopMemoryContext); + *tvp_type_schema_name = pstrdup((char *) get_logical_schema_name(typnamespace, true)); + MemoryContextSwitchTo(oldContext); + ReleaseSysCache(tuple); + } + + if(!xactStarted) + CommitTransactionCommand(); +} diff --git a/contrib/babelfishpg_tsql/src/catalog.h b/contrib/babelfishpg_tsql/src/catalog.h index 3e8e2c8169..c6ecfab882 100644 --- a/contrib/babelfishpg_tsql/src/catalog.h +++ b/contrib/babelfishpg_tsql/src/catalog.h @@ -581,4 +581,6 @@ typedef struct Rule RelData *tbldata; /* extra catalog info */ } Rule; +extern void get_tvp_typename_typeschemaname(char *proc_name, char *target_arg_name, char **tvp_type_name, char **tvp_type_schema_name); + #endif diff --git a/contrib/babelfishpg_tsql/src/extendedproperty.c b/contrib/babelfishpg_tsql/src/extendedproperty.c index d6f1c7c8b3..ad2719e1a8 100644 --- a/contrib/babelfishpg_tsql/src/extendedproperty.c +++ b/contrib/babelfishpg_tsql/src/extendedproperty.c @@ -1170,7 +1170,10 @@ get_extended_property_from_tuple(Relation relation, HeapTuple tuple, values[2] = datumCopy(datum, false, -1); datum = heap_getattr(tuple, Anum_bbf_extended_properties_value, RelationGetDescr(relation), &isnull); - values[3] = datumCopy(datum, false, -1); + if (!isnull) + values[3] = datumCopy(datum, false, -1); + else + nulls[3] = true; return true; } diff --git a/contrib/babelfishpg_tsql/src/hooks.c b/contrib/babelfishpg_tsql/src/hooks.c index 47941adf8e..be82e31dd7 100644 --- a/contrib/babelfishpg_tsql/src/hooks.c +++ b/contrib/babelfishpg_tsql/src/hooks.c @@ -108,7 +108,7 @@ static bool match_pltsql_func_call(HeapTuple proctup, int nargs, List *argnames, static ObjectAddress get_trigger_object_address(List *object, Relation *relp, bool missing_ok, bool object_from_input); Oid get_tsql_trigger_oid(List *object, const char *tsql_trigger_name, bool object_from_input); static Node *transform_like_in_add_constraint(Node *node); -static char** fetch_func_input_arg_names(HeapTuple func_tuple); +char** fetch_func_input_arg_names(HeapTuple func_tuple); /***************************************** * Analyzer Hooks @@ -4219,7 +4219,7 @@ static int getDefaultPosition(const List *default_positions, const ListCell *def * @param func_tuple or proc_tuple * @return char** list of input arg names */ -static char** fetch_func_input_arg_names(HeapTuple func_tuple) +char** fetch_func_input_arg_names(HeapTuple func_tuple) { Datum proargnames; Datum proargmodes; diff --git a/contrib/babelfishpg_tsql/src/hooks.h b/contrib/babelfishpg_tsql/src/hooks.h index 9c729e10e0..74a77a03fd 100644 --- a/contrib/babelfishpg_tsql/src/hooks.h +++ b/contrib/babelfishpg_tsql/src/hooks.h @@ -36,6 +36,7 @@ extern Datum pltsql_exec_tsql_cast_value(Datum value, bool *isnull, Oid reqtype, int32 reqtypmod); extern void pltsql_bbfSelectIntoUtility(ParseState *pstate, PlannedStmt *pstmt, const char *queryString, QueryEnvironment *queryEnv, ParamListInfo params, QueryCompletion *qc, ObjectAddress *address); +extern char** fetch_func_input_arg_names(HeapTuple func_tuple); extern char *update_delete_target_alias; extern bool sp_describe_first_result_set_inprogress; diff --git a/contrib/babelfishpg_tsql/src/pl_exec.c b/contrib/babelfishpg_tsql/src/pl_exec.c index 49126ada78..81a4a451b7 100644 --- a/contrib/babelfishpg_tsql/src/pl_exec.c +++ b/contrib/babelfishpg_tsql/src/pl_exec.c @@ -1036,9 +1036,10 @@ pltsql_exec_trigger(PLtsql_function *func, PLtsql_rec *rec_new, *rec_old; HeapTuple rettup; + bool support_tsql_trans = pltsql_support_tsql_transactions(); /* Check if this trigger is called as part of any of postgres' function, procedure or trigger. */ - if (!pltsql_support_tsql_transactions()) + if (!support_tsql_trans) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -1050,7 +1051,7 @@ pltsql_exec_trigger(PLtsql_function *func, */ pltsql_estate_setup(&estate, func, NULL, NULL); - if (pltsql_support_tsql_transactions() && !pltsql_disable_txn_in_triggers) + if (support_tsql_trans && !pltsql_disable_txn_in_triggers) estate.atomic = false; estate.trigdata = trigdata; @@ -1173,7 +1174,7 @@ pltsql_exec_trigger(PLtsql_function *func, * TSQL triggers terminate if there is no transaction active at the * end */ - if (pltsql_support_tsql_transactions() && !pltsql_disable_txn_in_triggers && NestedTranCount == 0) + if (support_tsql_trans && !pltsql_disable_txn_in_triggers && NestedTranCount == 0) ereport(ERROR, (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT), errmsg("The transaction ended in the trigger. The batch has been aborted."))); @@ -1181,7 +1182,7 @@ pltsql_exec_trigger(PLtsql_function *func, /* * If an error was encountered when executing trigger. */ - if (pltsql_support_tsql_transactions() && !pltsql_disable_txn_in_triggers && exec_state_call_stack->error_data.trigger_error) + if (support_tsql_trans && !pltsql_disable_txn_in_triggers && exec_state_call_stack->error_data.trigger_error) ereport(ERROR, (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION), errmsg("An error was raised during trigger execution. The batch has been aborted and the user transaction, if any, has been rolled back."))); @@ -4622,6 +4623,7 @@ exec_stmt_execsql(PLtsql_execstate *estate, bool fmtonly_enabled = true; CmdType cmd = CMD_UNKNOWN; bool enable_txn_in_triggers = !pltsql_disable_txn_in_triggers; + bool support_tsql_trans = pltsql_support_tsql_transactions(); StringInfoData query; bool need_path_reset = false; char *cur_dbname = get_cur_db_name(); @@ -4799,7 +4801,7 @@ exec_stmt_execsql(PLtsql_execstate *estate, /* Open nesting level in engine */ BeginCompositeTriggers(CurrentMemoryContext); /* TSQL commands must run inside an explicit transaction */ - if (!pltsql_disable_batch_auto_commit && pltsql_support_tsql_transactions() && + if (!pltsql_disable_batch_auto_commit && support_tsql_trans && stmt->txn_data == NULL && !IsTransactionBlockActive()) { MemoryContext oldCxt = CurrentMemoryContext; @@ -4825,7 +4827,7 @@ exec_stmt_execsql(PLtsql_execstate *estate, portal, expr, cmd, paramLI); else if (stmt->need_to_push_result) rc = execute_plan_and_push_result(estate, expr, paramLI); - else if (stmt->txn_data != NULL && !pltsql_support_tsql_transactions()) + else if (stmt->txn_data != NULL && !support_tsql_trans) { elog(DEBUG2, "TSQL TXN Execute transaction command with PG semantics"); rc = execute_txn_command(estate, stmt); @@ -5058,7 +5060,7 @@ exec_stmt_execsql(PLtsql_execstate *estate, */ /* TODO To let procedure call from PSQL work with old semantics */ if ((!pltsql_disable_batch_auto_commit || (stmt->txn_data != NULL)) && - pltsql_support_tsql_transactions() && + support_tsql_trans && (enable_txn_in_triggers || estate->trigdata == NULL) && !ro_func && !estate->insert_exec) { diff --git a/contrib/babelfishpg_tsql/src/pl_handler.c b/contrib/babelfishpg_tsql/src/pl_handler.c index e6e2349947..1c288cc376 100644 --- a/contrib/babelfishpg_tsql/src/pl_handler.c +++ b/contrib/babelfishpg_tsql/src/pl_handler.c @@ -149,7 +149,9 @@ extern bool pltsql_check_guc_plan(CachedPlanSource *plansource); bool pltsql_function_as_checker(const char *lang, List *as, char **prosrc_str_p, char **probin_str_p); extern void pltsql_function_probin_writer(CreateFunctionStmt *stmt, Oid languageOid, char **probin_str_p); extern void pltsql_function_probin_reader(ParseState *pstate, List *fargs, Oid *actual_arg_types, Oid *declared_arg_types, Oid funcid); -static void check_nullable_identity_constraint(RangeVar *relation, ColumnDef *column); +static void check_invalid_column_constraints(RangeVar *relation, ColumnDef *column); +static void check_invalid_constraints(RangeVar *relation, Constraint *constraint); +static bool checkAndSetTsqlSystemFunc(FuncCall *fc); static bool is_identity_constraint(ColumnDef *column); extern PLtsql_function *find_cached_batch(int handle); extern void apply_post_compile_actions(PLtsql_function *func, InlineCodeBlockArgs *args); @@ -1089,7 +1091,7 @@ pltsql_post_parse_analyze(ParseState *pstate, Query *query, JumbleState *jstate) switch (nodeTag(element)) { case T_ColumnDef: - check_nullable_identity_constraint(stmt->relation, + check_invalid_column_constraints(stmt->relation, (ColumnDef *) element); if (is_identity_constraint((ColumnDef *) element)) { @@ -1176,7 +1178,7 @@ pltsql_post_parse_analyze(ParseState *pstate, Query *query, JumbleState *jstate) switch (cmd->subtype) { case AT_AddColumn: - check_nullable_identity_constraint(atstmt->relation, + check_invalid_column_constraints(atstmt->relation, castNode(ColumnDef, cmd->def)); if (is_identity_constraint(castNode(ColumnDef, cmd->def))) { @@ -1204,6 +1206,8 @@ pltsql_post_parse_analyze(ParseState *pstate, Query *query, JumbleState *jstate) { Constraint *c = castNode(Constraint, cmd->def); + check_invalid_constraints(atstmt->relation, c); + if (rowversion_column_name) validate_rowversion_table_constraint(c, rowversion_column_name); } @@ -1254,6 +1258,17 @@ pltsql_post_parse_analyze(ParseState *pstate, Query *query, JumbleState *jstate) { int colnamelen = strlen(cmd->name); + if (nodeTag(cmd->def) == T_FuncCall) + { + if (atstmt->relation->relpersistence == RELPERSISTENCE_TEMP && + !checkAndSetTsqlSystemFunc(castNode(FuncCall, cmd->def))) + { + ereport(ERROR, + (errcode(ERRCODE_INVALID_COLUMN_DEFINITION), + errmsg("User-defined functions, partition functions, and column references are not allowed in expressions in this context."))); + } + } + /* * Disallow defaults on a rowversion * column. @@ -1907,9 +1922,13 @@ revoke_type_permission_from_public(PlannedStmt *pstmt, const char *queryString, CommandCounterIncrement(); } - +/* + * Check for constraints that are invalid in TSQL. For example: + * 1. Identity columns cannot be nullable + * 2. User-defined functions (UDFs) are not allowed in TSQL temp table or table variable column defaults. + */ static void -check_nullable_identity_constraint(RangeVar *relation, ColumnDef *column) +check_invalid_column_constraints(RangeVar *relation, ColumnDef *column) { ListCell *clist; bool is_null = false; @@ -1918,6 +1937,7 @@ check_nullable_identity_constraint(RangeVar *relation, ColumnDef *column) foreach(clist, column->constraints) { Constraint *constraint = lfirst_node(Constraint, clist); + check_invalid_constraints(relation, constraint); switch (constraint->contype) { @@ -1942,6 +1962,76 @@ check_nullable_identity_constraint(RangeVar *relation, ColumnDef *column) relation->relname))); } +/* + * Similar to check_invalid_column_constraints, but for individual constraints, such as added by + * ALTER TABLE ADD CONSTRAINT + */ +static void +check_invalid_constraints(RangeVar *relation, Constraint *constraint) +{ + switch (constraint->contype) + { + case CONSTR_DEFAULT: + { + if (IsA(constraint->raw_expr, FuncCall)) + { + FuncCall *fc = castNode(FuncCall, constraint->raw_expr); + if (relation->relpersistence == RELPERSISTENCE_TEMP && !checkAndSetTsqlSystemFunc(fc)) + { + ereport(ERROR, + (errcode(ERRCODE_INVALID_COLUMN_DEFINITION), + errmsg("User-defined functions, partition functions, and column references are not allowed in expressions in this context."))); + } + } + break; + } + + default: + break; + } +} + +/* + * Returns true iff the function is a system function. For Babelfish, this means searching in the "sys" + * schema, but the "sys" schema is meant to be opaque to customers, so to match SQL Server behavior + * we assume that it will never be schema-qualified in order to be true. + * If we do find a matching system function, then we modify the func call to explicitly call the fully-qualified + * system function, to prevent inadvertently using any user-defined overrides for the function name. + */ +static bool +checkAndSetTsqlSystemFunc(FuncCall *fc) +{ + List *name_to_search; + ObjectWithArgs *owa = makeNode(ObjectWithArgs); + char *sys = palloc0(4); + strncpy(sys, "sys", 3); + if (list_length(fc->funcname) == 1) + { + /* explicitly search in the "sys" schema */ + name_to_search = list_make2(makeString(sys), linitial(fc->funcname)); + } + else + { + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_COLUMN), + errmsg("Column \"%s\" is not allowed in this context, and the user-defined function or aggregate \"%s\" could not be found.", + strVal(linitial(fc->funcname)), + NameListToString(fc->funcname)))); + } + + owa->objname = name_to_search; + owa->args_unspecified = true; + + if (LookupFuncWithArgs(OBJECT_FUNCTION, owa, true)) + { + list_free(fc->funcname); + fc->funcname = name_to_search; + return true; + } + + return false; +} + static void pltsql_sequence_validate_increment(int64 increment_by, int64 max_value, @@ -5053,6 +5143,7 @@ _PG_init(void) (*pltsql_protocol_plugin_ptr)->tsql_char_input = common_utility_plugin_ptr->tsql_bpchar_input; (*pltsql_protocol_plugin_ptr)->get_cur_db_name = &get_cur_db_name; (*pltsql_protocol_plugin_ptr)->get_physical_schema_name = &get_physical_schema_name; + (*pltsql_protocol_plugin_ptr)->get_tvp_typename_typeschemaname = &get_tvp_typename_typeschemaname; (*pltsql_protocol_plugin_ptr)->quoted_identifier = pltsql_quoted_identifier; (*pltsql_protocol_plugin_ptr)->arithabort = pltsql_arithabort; diff --git a/contrib/babelfishpg_tsql/src/pltsql.h b/contrib/babelfishpg_tsql/src/pltsql.h index a2191367b9..86772d9e29 100644 --- a/contrib/babelfishpg_tsql/src/pltsql.h +++ b/contrib/babelfishpg_tsql/src/pltsql.h @@ -1801,7 +1801,8 @@ typedef struct PLtsql_protocol_plugin void (*set_reset_tds_connection_flag) (); bool (*get_reset_tds_connection_flag) (); - + void (*get_tvp_typename_typeschemaname) (char *proc_name, char *target_arg_name, + char **tvp_type_name, char **tvp_type_schema_name); /* Session level GUCs */ bool quoted_identifier; bool arithabort; @@ -2245,6 +2246,7 @@ extern bool is_tsql_nchar_or_nvarchar_datatype(Oid oid); /* sys.nchar / sys.nvar extern bool is_tsql_binary_or_varbinary_datatype(Oid oid); /* sys.binary / sys.varbinary */ extern bool is_tsql_datatype_with_max_scale_expr_allowed(Oid oid); /* sys.varchar(max), sys.nvarchar(max), sys.varbinary(max) */ extern bool is_tsql_text_ntext_or_image_datatype(Oid oid); /* sys.text, sys.ntext, sys.image */ +extern void downcase_truncate_split_object_name(char *four_part_object_name, char** server_name, char** db_name, char** schema_name, char** object_name); typedef struct { diff --git a/contrib/babelfishpg_tsql/src/pltsql_coerce.c b/contrib/babelfishpg_tsql/src/pltsql_coerce.c index b2cd73ff1f..f6688951c3 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_coerce.c +++ b/contrib/babelfishpg_tsql/src/pltsql_coerce.c @@ -54,6 +54,7 @@ /* Hooks for engine*/ extern find_coercion_pathway_hook_type find_coercion_pathway_hook; extern determine_datatype_precedence_hook_type determine_datatype_precedence_hook; +extern is_tsql_base_datatype_hook_type is_tsql_base_datatype_hook; extern func_select_candidate_hook_type func_select_candidate_hook; extern coerce_string_literal_hook_type coerce_string_literal_hook; extern select_common_type_hook_type select_common_type_hook; @@ -847,6 +848,15 @@ tsql_has_higher_precedence(Oid typeId1, Oid typeId2) return type1_precedence < type2_precedence; } +/* + * Returns if given data type is a base type in T-SQL. + */ +static bool +is_tsql_base_datatype(Oid typeId) +{ + return tsql_get_type_precedence(typeId) != -1; +} + static bool is_vectorized_binary_operator(FuncCandidateList candidate) { @@ -2168,6 +2178,7 @@ init_tsql_datatype_precedence_hash_tab(PG_FUNCTION_ARGS) /* Register Hooks */ determine_datatype_precedence_hook = tsql_has_higher_precedence; + is_tsql_base_datatype_hook = is_tsql_base_datatype; func_select_candidate_hook = tsql_func_select_candidate; coerce_string_literal_hook = tsql_coerce_string_literal_hook; select_common_type_hook = tsql_select_common_type_hook; diff --git a/contrib/babelfishpg_tsql/src/pltsql_utils.c b/contrib/babelfishpg_tsql/src/pltsql_utils.c index fe242fa36d..1fb586768b 100644 --- a/contrib/babelfishpg_tsql/src/pltsql_utils.c +++ b/contrib/babelfishpg_tsql/src/pltsql_utils.c @@ -31,6 +31,7 @@ #include "multidb.h" #include "session.h" #include "rolecmds.h" +#include "parser/scansup.h" common_utility_plugin *common_utility_plugin_ptr = NULL; @@ -2650,3 +2651,57 @@ update_GrantRoleStmtByName(Node *n, const char *granted_role, const char *grante update_GrantRoleStmt(n, list_make1(granted_rolespec), list_make1(grantee_rolespec), NULL); } + +/* + * downcase_truncate_split_object_name: + * Resolve the four part object name. Downcase and truncate identifier if needed. + * Specify NULL for any of the server_name, db_name, schema_name, object_name if + * we don't need to resolve them. + */ +void +downcase_truncate_split_object_name(char *four_part_object_name, char **server_name, + char **db_name, char **schema_name, char **object_name) +{ + char **splited_object_name; + char *temp_server_name; + char *temp_db_name; + char *temp_schema_name; + char *temp_object_name; + + /* Resolve the four part name. */ + splited_object_name = split_object_name(four_part_object_name); + temp_server_name = splited_object_name[0]; + temp_db_name = splited_object_name[1]; + temp_schema_name = splited_object_name[2]; + temp_object_name = splited_object_name[3]; + + /* Downcase identifier if needed. */ + if (pltsql_case_insensitive_identifiers) + { + temp_server_name = downcase_identifier(temp_server_name, strlen(temp_server_name), false, false); + temp_db_name = downcase_identifier(temp_db_name, strlen(temp_db_name), false, false); + temp_schema_name = downcase_identifier(temp_schema_name, strlen(temp_schema_name), false, false); + temp_object_name = downcase_identifier(temp_object_name, strlen(temp_object_name), false, false); + for (int j = 0; j < 4; j++) + pfree(splited_object_name[j]); + } + else + pfree(splited_object_name[0]); + + pfree(splited_object_name); + + /* Truncate identifiers if needed. */ + truncate_tsql_identifier(temp_server_name); + truncate_tsql_identifier(temp_db_name); + truncate_tsql_identifier(temp_schema_name); + truncate_tsql_identifier(temp_object_name); + + if (server_name != NULL) + *server_name = temp_server_name; + if (db_name != NULL) + *db_name = temp_db_name; + if (schema_name != NULL) + *schema_name = temp_schema_name; + if (object_name != NULL) + *object_name = temp_object_name; +} diff --git a/contrib/babelfishpg_tsql/src/procedures.c b/contrib/babelfishpg_tsql/src/procedures.c index 93e0ed6cb4..5ee3079e81 100644 --- a/contrib/babelfishpg_tsql/src/procedures.c +++ b/contrib/babelfishpg_tsql/src/procedures.c @@ -51,9 +51,7 @@ #include "catalog.h" #include "extendedproperty.h" #include "multidb.h" -#include "pltsql.h" #include "session.h" -#include "pltsql.h" #include "rolecmds.h" PG_FUNCTION_INFO_V1(sp_unprepare); @@ -3386,38 +3384,24 @@ sp_babelfish_volatility(PG_FUNCTION_ARGS) char *full_function_name = NULL; char *logical_schema_name = NULL; char *physical_schema_name = NULL; - char **splited_object_name; + char *server_name; + char *object_name; + char *database_name; - /* get physical schema name */ - splited_object_name = split_object_name(function_name); + /* + * Split the function name, downcase and truncate if needed + * and return the server_name, db_name, schema_name and object_name. + */ + downcase_truncate_split_object_name(function_name, &server_name, &database_name, &logical_schema_name, &object_name); - if (strcmp(splited_object_name[0], "") || strcmp(splited_object_name[1], "")) + if (strcmp(server_name, "") || strcmp(database_name, "")) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("function \"%s\" is not a valid two part name", function_name))); pfree(function_name); - logical_schema_name = splited_object_name[2]; - function_name = splited_object_name[3]; - - /* downcase identifier */ - if (pltsql_case_insensitive_identifiers) - { - logical_schema_name = downcase_identifier(logical_schema_name, strlen(logical_schema_name), false, false); - function_name = downcase_identifier(function_name, strlen(function_name), false, false); - for (int j = 0; j < 4; j++) - pfree(splited_object_name[j]); - } - else - { - pfree(splited_object_name[0]); - pfree(splited_object_name[1]); - } - pfree(splited_object_name); - /* truncate identifiers if needed */ - truncate_tsql_identifier(logical_schema_name); - truncate_tsql_identifier(function_name); + function_name = object_name; if (!strcmp(function_name, "")) ereport(ERROR, diff --git a/contrib/babelfishpg_tsql/src/tablecmds.c b/contrib/babelfishpg_tsql/src/tablecmds.c index a53d13881e..04cd1f3578 100644 --- a/contrib/babelfishpg_tsql/src/tablecmds.c +++ b/contrib/babelfishpg_tsql/src/tablecmds.c @@ -130,7 +130,7 @@ lookup_and_drop_triggers(ObjectAccessType access, Oid classId, return; /* We only want to execute this function for the DROP TABLE case */ - if (classId != RelationRelationId || access != OAT_DROP) + if (classId != RelationRelationId || access != OAT_DROP || subId != 0) return; /* diff --git a/dev-tools.sh b/dev-tools.sh index eb6b21f5db..13a311cf67 100755 --- a/dev-tools.sh +++ b/dev-tools.sh @@ -110,7 +110,7 @@ if [ ! $TARGET_WS ]; then fi echo "Target Workspace: $TARGET_WS" -TEST_DB="jdbc_testdb" +TEST_DB="babelfish_db" cd $TARGET_WS if [ ! -d "./postgresql_modified_for_babelfish" ]; then @@ -198,10 +198,10 @@ pg_dump() { if [[ ! $2 ]];then $1/postgres/bin/pg_dumpall --username jdbc_user --roles-only --quote-all-identifiers --verbose -f pg_dump_globals.sql 2>error.log - $1/postgres/bin/pg_dump --create --username jdbc_user --column-inserts --quote-all-identifiers --verbose --file="pg_dump.sql" --dbname=jdbc_testdb 2>>error.log + $1/postgres/bin/pg_dump --create --username jdbc_user --column-inserts --quote-all-identifiers --verbose --file="pg_dump.sql" --dbname=babelfish_db 2>>error.log else $1/postgres/bin/pg_dumpall --username jdbc_user --roles-only --quote-all-identifiers --verbose --bbf-database-name=$2 -f pg_dump_globals.sql 2>error.log - $1/postgres/bin/pg_dump --username jdbc_user --column-inserts --quote-all-identifiers --verbose --bbf-database-name=$2 --file="pg_dump.sql" --dbname=jdbc_testdb 2>>error.log + $1/postgres/bin/pg_dump --username jdbc_user --column-inserts --quote-all-identifiers --verbose --bbf-database-name=$2 --file="pg_dump.sql" --dbname=babelfish_db 2>>error.log fi stop $1 } @@ -213,15 +213,15 @@ restore() { rm -f error.log echo "Restoring from pg_dumpall" $2/postgres/bin/psql -d postgres -U $USER -f $1/postgres/pg_dump_globals.sql 2>error.log - $2/postgres/bin/psql -d postgres -U $USER -c "CREATE DATABASE jdbc_testdb OWNER jdbc_user;" + $2/postgres/bin/psql -d postgres -U $USER -c "CREATE DATABASE babelfish_db OWNER jdbc_user;" echo "Restoring from pg_dump" if [[ ! $3 ]];then $2/postgres/bin/psql -d postgres -U jdbc_user -f $1/postgres/pg_dump.sql 2>>error.log - $2/postgres/bin/psql -d jdbc_testdb -U jdbc_user -c "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb';" - $2/postgres/bin/psql -d jdbc_testdb -U jdbc_user -c "SELECT pg_reload_conf();" + $2/postgres/bin/psql -d babelfish_db -U jdbc_user -c "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'babelfish_db';" + $2/postgres/bin/psql -d babelfish_db -U jdbc_user -c "SELECT pg_reload_conf();" else - $2/postgres/bin/psql -d jdbc_testdb -U jdbc_user -f $1/postgres/pg_dump.sql 2>>error.log + $2/postgres/bin/psql -d babelfish_db -U jdbc_user -f $1/postgres/pg_dump.sql 2>>error.log fi } @@ -391,7 +391,7 @@ elif [ "$1" == "pg_upgrade" ]; then bin/psql -d $TEST_DB -U $USER -c \ "ALTER EXTENSION babelfishpg_common UPDATE; ALTER EXTENSION babelfishpg_tsql UPDATE;" bin/psql -d $TEST_DB -U $USER -c \ - "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb';" + "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'babelfish_db';" bin/psql -d $TEST_DB -U $USER -c \ "SELECT pg_reload_conf();" exit 0 diff --git a/test/JDBC/cleanup.sh b/test/JDBC/cleanup.sh index f536d3c68b..7b33703d32 100755 --- a/test/JDBC/cleanup.sh +++ b/test/JDBC/cleanup.sh @@ -1,12 +1,12 @@ echo "===================================== CLEANING UP ======================================" psql -d postgres -U "$USER" << EOF -\c jdbc_testdb +\c babelfish_db CALL sys.remove_babelfish(); ALTER SYSTEM RESET babelfishpg_tsql.database_name; ALTER SYSTEM RESET babelfishpg_tsql.migration_mode; SELECT pg_reload_conf(); \c postgres -DROP DATABASE jdbc_testdb WITH (FORCE); +DROP DATABASE babelfish_db WITH (FORCE); DROP OWNED BY jdbc_user; DROP USER jdbc_user; EOF diff --git a/test/JDBC/expected/BABEL-3392-vu-verify.out b/test/JDBC/expected/BABEL-3392-vu-verify.out index bcff76215e..30963fcb3a 100644 --- a/test/JDBC/expected/BABEL-3392-vu-verify.out +++ b/test/JDBC/expected/BABEL-3392-vu-verify.out @@ -1637,7 +1637,7 @@ SELECT name, max_length FROM sys.columns WHERE name = 'babel4157_c1' GO ~~START~~ varchar#!#smallint -babel4157_c1#!# +babel4157_c1#!#3 ~~END~~ @@ -1890,14 +1890,14 @@ select cast(17 as varbinary(1)) UNION select cast(10 as varbinary(2)) union sele GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type "nchar" to bbf_varbinary)~~ +~~ERROR (Message: UNION could not convert type "nchar" to varbinary)~~ SELECT CAST(N'ΘЖऌฒ' AS NCHAR(15)) UNION select cast(10 as varbinary(2)); GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type varbinary to bpchar)~~ +~~ERROR (Message: UNION could not convert type varbinary to "nchar")~~ SELECT CAST(1 as BIT) UNION SELECT cast(N'ab' as NCHAR(10)) UNION SELECT CAST('bar' as CHAR(10)); diff --git a/test/JDBC/expected/BABEL-5054-vu-prepare.out b/test/JDBC/expected/BABEL-5054-vu-prepare.out new file mode 100644 index 0000000000..8266acd4d8 --- /dev/null +++ b/test/JDBC/expected/BABEL-5054-vu-prepare.out @@ -0,0 +1,2663 @@ +CREATE PROCEDURE BABEL_5054_vu_prepare_p1 +AS +BEGIN + DECLARE @jsonInventory NVARCHAR(MAX) = N'{ + "Warehouse": { + "WarehouseID": { + "ScanDate": "2023-01-03", + "FacilityCode": "WHSE01", + "InventoryType": "ProductType", + "ValidFrom": "2023-01-03", + "ValidTo": "2023-02-28", + "Zones": "ZONE_A,ZONE_B,ZONE_C", + "Sections": "SEC1,SEC2,SEC3", + "IsActive": "true", + "RequestMode": "STANDARD", + "MaxResults": "100", + "LocationID": "LOC123", + "TrackingEnabled": "true", + "BatchNumber": "BTH2023001", + "SensorID": "1234", + "ReadingID": "5678" + }, + "SystemMetadata": { + "TotalDays": "30", + "TotalRecords": "15", + "HasMoreRecords": "false", + "IsComplete": "true", + "LastUpdate": "2023-01-03T14:30:00", + "ProcessingTime": "1.5", + "DataQuality": "HIGH" + }, + "FacilityDailyStatusArray": { + "FacilityDailyStatus": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "100", + "MaintenanceSpace": "50", + "AvailableSpace": "800", + "AllocatedSpace": "100", + "TotalUsed": "200", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "8", + "OperationalHours": "24", + "PowerConsumption": "450.75", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-04", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-05", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-06", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-07", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-08", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-09", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-10", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + } + ] + }, + "StorageTypeArray": { + "StorageType": [ + { + "StorageCode": "COLD", + "StorageName": "Cold Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "false", + "Zone": "ZONE_A", + "MaxWeight": "5000", + "StorageClass": "CLASS_A", + "SecurityLevel": "HIGH", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "500", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "400", + "AllocatedSpace": "50", + "TotalUsed": "100", + "TotalCapacity": "500", + "Temperature": "-18.5", + "Humidity": "45", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-02-01", + "AlertCount": "0", + "DoorOpenCount": "24", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + }, + { + "Date": "2023-01-04", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "500", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "380", + "AllocatedSpace": "70", + "TotalUsed": "120", + "TotalCapacity": "500", + "Temperature": "-18.2", + "Humidity": "44", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-02-01", + "AlertCount": "1", + "DoorOpenCount": "28", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + } + ] + } + }, + { + "StorageCode": "FRSH", + "StorageName": "Fresh Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "false", + "Zone": "ZONE_B", + "MaxWeight": "3000", + "StorageClass": "CLASS_B", + "SecurityLevel": "MEDIUM", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "300", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "200", + "AllocatedSpace": "50", + "TotalUsed": "100", + "TotalCapacity": "300", + "Temperature": "4.2", + "Humidity": "65", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-02", + "NextMaintenance": "2023-02-02", + "AlertCount": "0", + "DoorOpenCount": "35", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + } + ] + } + }, + { + "StorageCode": "HAZMT", + "StorageName": "Hazmat Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "true", + "Zone": "ZONE_C", + "MaxWeight": "2000", + "StorageClass": "CLASS_H", + "SecurityLevel": "MAXIMUM", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "200", + "RestrictedAccess": "true", + "MinStaffing": "3", + "AvailableSpace": "150", + "AllocatedSpace": "30", + "TotalUsed": "50", + "TotalCapacity": "200", + "Temperature": "21.0", + "Humidity": "40", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-01-15", + "AlertCount": "0", + "DoorOpenCount": "12", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL", + "HazmatIncidents": "0", + "SafetyInspectionStatus": "PASSED", + "EmergencyResponseReady": "true" + } + ] + } + } + ] + }, + "EnvironmentalMetrics": { + "AirQuality": "GOOD", + "CO2Levels": "450", + "NoiseLevel": "65", + "LightingLevel": "800", + "WaterUsage": "1250", + "WasteManagement": "OPTIMAL", + "RecyclingRate": "85.5" + }, + "SecurityStatus": { + "AccessControlStatus": "ACTIVE", + "SecurityPersonnel": "4", + "CameraStatus": "OPERATIONAL", + "LastIncident": "2022-12-15", + "ThreatLevel": "LOW", + "PerimeterStatus": "SECURE" + } + } + }' + SELECT + WarehouseID.FacilityCode AS FacilityCode, + StorageArr.StorageCode AS Storage_Code, + [Date] AS Metric_Date, + AvailableSpace AS Available_Space, + TotalUsed AS Total_Used, + IsOperational AS Is_Operational, + Temperature AS Storage_Temp, + Humidity AS Storage_Humidity + FROM OPENJSON(@jsonInventory) WITH ( + WarehouseID NVARCHAR(MAX) '$.Warehouse.WarehouseID' AS JSON, + StorageTypeArray NVARCHAR(MAX) '$.Warehouse.StorageTypeArray' AS JSON + ) AS [Warehouse] + OUTER APPLY OPENJSON([Warehouse].WarehouseID) WITH ( + FacilityCode VARCHAR(15) '$.FacilityCode' + ) AS WarehouseID + OUTER APPLY OPENJSON([Warehouse].StorageTypeArray) WITH ( + StorageType NVARCHAR(MAX) '$.StorageType' AS JSON + ) AS Storage + OUTER APPLY OPENJSON(Storage.StorageType) WITH ( + StorageCode VARCHAR(6) '$.StorageCode', + DailyMetricsArray NVARCHAR(MAX) '$.DailyMetricsArray' AS JSON + ) AS StorageArr + OUTER APPLY OPENJSON(StorageArr.DailyMetricsArray) WITH ( + DailyMetrics NVARCHAR(MAX) '$.DailyMetrics' AS JSON + ) AS Metrics + OUTER APPLY OPENJSON(Metrics.DailyMetrics) WITH ( + [Date] DATE '$.Date', + AvailableSpace INT '$.AvailableSpace', + TotalUsed INT '$.TotalUsed', + IsOperational VARCHAR(10) '$.IsOperational', + Temperature DECIMAL(5,2) '$.Temperature', + Humidity INT '$.Humidity' + ) AS DailyMetrics +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p2 +AS +BEGIN + DECLARE @jsonProduction NVARCHAR(MAX) = N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + -- Query to analyze production metrics + SELECT + ProductionID.PlantCode, + MachineArr.MachineCode, + MachineArr.MachineName, + Metrics.DateTime, + Metrics.OperationalStatus, + Metrics.CycleTime, + Metrics.ProductCount, + Metrics.PowerConsumption, + Metrics.OEEScore, + Metrics.MaintenanceScore + FROM OPENJSON(@jsonProduction) WITH ( + ProductionID NVARCHAR(MAX) '$.Factory.ProductionID' AS JSON, + MachineStatusArray NVARCHAR(MAX) '$.Factory.MachineStatusArray' AS JSON + ) AS Factory + OUTER APPLY OPENJSON(Factory.ProductionID) WITH ( + PlantCode VARCHAR(10) '$.PlantCode' + ) AS ProductionID + OUTER APPLY OPENJSON(Factory.MachineStatusArray) WITH ( + MachineStatus NVARCHAR(MAX) '$.MachineStatus' AS JSON + ) AS Machines + OUTER APPLY OPENJSON(Machines.MachineStatus) WITH ( + MachineCode VARCHAR(10) '$.MachineCode', + MachineName VARCHAR(50) '$.MachineName', + HourlyMetricsArray NVARCHAR(MAX) '$.HourlyMetricsArray' AS JSON + ) AS MachineArr + OUTER APPLY OPENJSON(MachineArr.HourlyMetricsArray) WITH ( + HourlyMetrics NVARCHAR(MAX) '$.HourlyMetrics' AS JSON + ) AS HourlyData + OUTER APPLY OPENJSON(HourlyData.HourlyMetrics) WITH ( + DateTime DATETIME '$.DateTime', + OperationalStatus VARCHAR(20) '$.OperationalStatus', + CycleTime DECIMAL(10,2) '$.CycleTime', + ProductCount INT '$.ProductCount', + PowerConsumption DECIMAL(10,2) '$.PowerConsumption', + OEEScore DECIMAL(5,2) '$.OEEScore', + MaintenanceScore DECIMAL(5,2) '$.MaintenanceScore' + ) AS Metrics + WHERE Metrics.DateTime IS NOT NULL + ORDER BY Metrics.DateTime, MachineArr.MachineCode +END; +GO + + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p3 +AS +BEGIN + DECLARE @jsonHealthcare NVARCHAR(MAX) = N'{ + "Hospital": { + "MonitoringSession": { + "SessionID": "MON20230103001", + "FacilityCode": "HOSP001", + "UnitCode": "ICU", + "FloorNumber": "3", + "WardCode": "ICU-A", + "StartTime": "2023-01-03T00:00:00", + "EndTime": "2023-01-03T23:59:59", + "StaffShift": "SHIFT_A", + "MonitoringLevel": "INTENSIVE", + "AlertProtocol": "STANDARD", + "DataInterval": "5", + "ResponsiblePhysician": "DR_SMITH", + "NursingTeam": "TEAM_A", + "EmergencyStatus": "NORMAL" + }, + "SystemConfiguration": { + "MonitoringDuration": "24", + "SamplingFrequency": "12", + "DataRetention": "90", + "BackupFrequency": "15", + "AlertThreshold": "CUSTOM", + "EncryptionLevel": "AES256", + "ComplianceMode": "HIPAA", + "DataValidation": "ENABLED" + }, + "PatientMonitoringArray": { + "PatientMonitoring": [ + { + "PatientID": "PT100123", + "AdmissionID": "ADM20230102003", + "Age": "65", + "Gender": "M", + "RiskLevel": "HIGH", + "IsolationStatus": "NONE", + "DiagnosisCode": "ICD10-I21.0", + "VitalSignsArray": { + "VitalSigns": [ + { + "DateTime": "2023-01-03T06:00:00", + "HeartRate": "82", + "BloodPressureSystolic": "135", + "BloodPressureDiastolic": "85", + "Temperature": "37.2", + "RespiratoryRate": "16", + "OxygenSaturation": "97", + "ConsciousnessLevel": "ALERT", + "PainScore": "2", + "GlucoseLevel": "110", + "EtCO2": "35", + "MAP": "95", + "CVP": "8", + "UrinePH": "6.5", + "UrineOutput": "50", + "FluidBalance": "-120", + "NEWS2Score": "2", + "AlertStatus": "NORMAL", + "InterventionRequired": "false" + }, + { + "DateTime": "2023-01-03T07:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T08:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T09:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T10:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T11:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T12:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + } + ] + } + }, + { + "PatientID": "PT100124", + "AdmissionID": "ADM20230102004", + "Age": "45", + "Gender": "F", + "RiskLevel": "MEDIUM", + "IsolationStatus": "CONTACT", + "DiagnosisCode": "ICD10-J18.9", + "VitalSignsArray": { + "VitalSigns": [ + { + "DateTime": "2023-01-03T06:00:00", + "HeartRate": "75", + "BloodPressureSystolic": "122", + "BloodPressureDiastolic": "78", + "Temperature": "38.5", + "RespiratoryRate": "20", + "OxygenSaturation": "94", + "ConsciousnessLevel": "ALERT", + "PainScore": "4", + "GlucoseLevel": "105", + "EtCO2": "38", + "MAP": "92", + "CVP": "7", + "UrinePH": "6.2", + "UrineOutput": "40", + "FluidBalance": "-200", + "NEWS2Score": "4", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + } + ] + } + } + ] + }, + "MedicalDeviceArray": { + "MedicalDevice": [ + { + "DeviceID": "VEN001", + "DeviceType": "VENTILATOR", + "Manufacturer": "MEDTECH", + "Model": "VENT-2000", + "LastCalibration": "2022-12-15", + "NextCalibration": "2023-03-15", + "AssignedPatient": "PT100123", + "MetricsArray": { + "Metrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "Mode": "SIMV", + "TidalVolume": "450", + "RespiratoryRate": "16", + "PEEP": "5", + "FiO2": "40", + "PIP": "25", + "InspiratoryPressure": "15", + "ExpiratoryPressure": "5", + "MinuteVolume": "7.2", + "AlarmStatus": "NORMAL", + "BatteryLevel": "85", + "MaintenanceStatus": "OK", + "ComplianceScore": "98.5", + "ErrorCount": "0" + } + ] + } + }, + { + "DeviceID": "INF001", + "DeviceType": "INFUSION_PUMP", + "Manufacturer": "MEDTECH", + "Model": "INFUS-3000", + "LastCalibration": "2022-12-20", + "NextCalibration": "2023-03-20", + "AssignedPatient": "PT100124", + "MetricsArray": { + "Metrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "FlowRate": "125", + "TotalVolume": "500", + "InfusedVolume": "125", + "RemainingVolume": "375", + "DrugConcentration": "50", + "DoseRate": "6.25", + "OcclusionPressure": "150", + "BatteryLevel": "90", + "AlarmStatus": "NORMAL", + "MaintenanceStatus": "OK", + "ErrorCount": "0" + } + ] + } + } + ] + }, + "EnvironmentalMetrics": { + "RoomTemperature": "21.5", + "Humidity": "45", + "AirPressure": "101.3", + "AirExchangeRate": "12", + "CO2Level": "450", + "LightLevel": "250", + "NoiseLevel": "45", + "IsolationPressure": "-2.5" + }, + "QualityMetrics": { + "InfectionRate": "0.1", + "HandHygieneCompliance": "95.5", + "PatientFallRate": "0.0", + "MedicationErrors": "0", + "BedOccupancyRate": "85.5", + "AverageResponseTime": "2.5", + "PatientSatisfaction": "92.0" + } + } + }' + -- Query to analyze patient vital signs and device metrics + SELECT + m.SessionID, + p.PatientID, + p.DiagnosisCode, + v.DateTime, + v.HeartRate, + v.BloodPressureSystolic, + v.BloodPressureDiastolic, + v.Temperature, + v.OxygenSaturation, + v.NEWS2Score, + v.AlertStatus, + d.DeviceID, + d.DeviceType, + dm.OperationalStatus, + dm.AlarmStatus + FROM OPENJSON(@jsonHealthcare) WITH ( + MonitoringSession NVARCHAR(MAX) '$.Hospital.MonitoringSession' AS JSON, + PatientMonitoringArray NVARCHAR(MAX) '$.Hospital.PatientMonitoringArray' AS JSON, + MedicalDeviceArray NVARCHAR(MAX) '$.Hospital.MedicalDeviceArray' AS JSON + ) AS Hospital + OUTER APPLY OPENJSON(Hospital.MonitoringSession) WITH ( + SessionID VARCHAR(20) '$.SessionID' + ) AS m + OUTER APPLY OPENJSON(Hospital.PatientMonitoringArray) WITH ( + PatientMonitoring NVARCHAR(MAX) '$.PatientMonitoring' AS JSON + ) AS Patients + OUTER APPLY OPENJSON(Patients.PatientMonitoring) WITH ( + PatientID VARCHAR(10) '$.PatientID', + DiagnosisCode VARCHAR(20) '$.DiagnosisCode', + VitalSignsArray NVARCHAR(MAX) '$.VitalSignsArray' AS JSON + ) AS p + OUTER APPLY OPENJSON(p.VitalSignsArray) WITH ( + VitalSigns NVARCHAR(MAX) '$.VitalSigns' AS JSON + ) AS Vitals + OUTER APPLY OPENJSON(Vitals.VitalSigns) WITH ( + DateTime DATETIME '$.DateTime', + HeartRate INT '$.HeartRate', + BloodPressureSystolic INT '$.BloodPressureSystolic', + BloodPressureDiastolic INT '$.BloodPressureDiastolic', + Temperature DECIMAL(4,1) '$.Temperature', + OxygenSaturation INT '$.OxygenSaturation', + NEWS2Score INT '$.NEWS2Score', + AlertStatus VARCHAR(20) '$.AlertStatus' + ) AS v + OUTER APPLY OPENJSON(Hospital.MedicalDeviceArray) WITH ( + MedicalDevice NVARCHAR(MAX) '$.MedicalDevice' AS JSON + ) AS Devices + OUTER APPLY OPENJSON(Devices.MedicalDevice) WITH ( + DeviceID VARCHAR(10) '$.DeviceID', + DeviceType VARCHAR(20) '$.DeviceType', + AssignedPatient VARCHAR(10) '$.AssignedPatient', + MetricsArray NVARCHAR(MAX) '$.MetricsArray' AS JSON + ) AS d + OUTER APPLY OPENJSON(d.MetricsArray) WITH ( + Metrics NVARCHAR(MAX) '$.Metrics' AS JSON + ) AS DeviceMetrics + OUTER APPLY OPENJSON(DeviceMetrics.Metrics) WITH ( + DateTime DATETIME '$.DateTime', + OperationalStatus VARCHAR(20) '$.OperationalStatus', + AlarmStatus VARCHAR(20) '$.AlarmStatus' + ) AS dm + WHERE p.PatientID = d.AssignedPatient + AND v.DateTime = dm.DateTime + ORDER BY v.DateTime, p.PatientID +END; +GO + + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p4 +AS +BEGIN + DECLARE @json NVARCHAR(MAX); + SET @json=N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + SELECT * FROM OPENJSON(@json, '$') with (name nvarchar(max) '$' AS JSON) +END; +GO + + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p5 +AS +BEGIN + DECLARE @json NVARCHAR(MAX); + SET @json=N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + SELECT * FROM OPENJSON(@json, '$') with (name sys.nvarchar(max) '$' AS JSON) +END; +GO + + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p6 +AS +BEGIN + DECLARE @json NVARCHAR(MAX); + SET @json=N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + SELECT * FROM OPENJSON(@json, '$') with (name nvarchar(max) '$.Factory' AS JSON) +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p7 + @jsonInventory NVARCHAR(MAX) +AS +BEGIN + SELECT + WarehouseID.FacilityCode AS FacilityCode, + StorageArr.StorageCode AS Storage_Code, + [Date] AS Metric_Date, + AvailableSpace AS Available_Space, + TotalUsed AS Total_Used, + IsOperational AS Is_Operational, + Temperature AS Storage_Temp, + Humidity AS Storage_Humidity + FROM OPENJSON(@jsonInventory) WITH ( + WarehouseID NVARCHAR(MAX) '$.Warehouse.WarehouseID' AS JSON, + StorageTypeArray NVARCHAR(MAX) '$.Warehouse.StorageTypeArray' AS JSON + ) AS [Warehouse] + OUTER APPLY OPENJSON([Warehouse].WarehouseID) WITH ( + FacilityCode VARCHAR(15) '$.FacilityCode' + ) AS WarehouseID + OUTER APPLY OPENJSON([Warehouse].StorageTypeArray) WITH ( + StorageType NVARCHAR(MAX) '$.StorageType' AS JSON + ) AS Storage + OUTER APPLY OPENJSON(Storage.StorageType) WITH ( + StorageCode VARCHAR(6) '$.StorageCode', + DailyMetricsArray NVARCHAR(MAX) '$.DailyMetricsArray' AS JSON + ) AS StorageArr + OUTER APPLY OPENJSON(StorageArr.DailyMetricsArray) WITH ( + DailyMetrics NVARCHAR(MAX) '$.DailyMetrics' AS JSON + ) AS Metrics + OUTER APPLY OPENJSON(Metrics.DailyMetrics) WITH ( + [Date] DATE '$.Date', + AvailableSpace INT '$.AvailableSpace', + TotalUsed INT '$.TotalUsed', + IsOperational VARCHAR(10) '$.IsOperational', + Temperature DECIMAL(5,2) '$.Temperature', + Humidity INT '$.Humidity' + ) AS DailyMetrics +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p8 + @jsonProduction NVARCHAR(MAX) +AS +BEGIN + SELECT + ProductionID.PlantCode, + MachineArr.MachineCode, + MachineArr.MachineName, + Metrics.DateTime, + Metrics.OperationalStatus, + Metrics.CycleTime, + Metrics.ProductCount, + Metrics.PowerConsumption, + Metrics.OEEScore, + Metrics.MaintenanceScore + FROM OPENJSON(@jsonProduction) WITH ( + ProductionID NVARCHAR(MAX) '$.Factory.ProductionID' AS JSON, + MachineStatusArray NVARCHAR(MAX) '$.Factory.MachineStatusArray' AS JSON + ) AS Factory + OUTER APPLY OPENJSON(Factory.ProductionID) WITH ( + PlantCode VARCHAR(10) '$.PlantCode' + ) AS ProductionID + OUTER APPLY OPENJSON(Factory.MachineStatusArray) WITH ( + MachineStatus NVARCHAR(MAX) '$.MachineStatus' AS JSON + ) AS Machines + OUTER APPLY OPENJSON(Machines.MachineStatus) WITH ( + MachineCode VARCHAR(10) '$.MachineCode', + MachineName VARCHAR(50) '$.MachineName', + HourlyMetricsArray NVARCHAR(MAX) '$.HourlyMetricsArray' AS JSON + ) AS MachineArr + OUTER APPLY OPENJSON(MachineArr.HourlyMetricsArray) WITH ( + HourlyMetrics NVARCHAR(MAX) '$.HourlyMetrics' AS JSON + ) AS HourlyData + OUTER APPLY OPENJSON(HourlyData.HourlyMetrics) WITH ( + DateTime DATETIME '$.DateTime', + OperationalStatus VARCHAR(20) '$.OperationalStatus', + CycleTime DECIMAL(10,2) '$.CycleTime', + ProductCount INT '$.ProductCount', + PowerConsumption DECIMAL(10,2) '$.PowerConsumption', + OEEScore DECIMAL(5,2) '$.OEEScore', + MaintenanceScore DECIMAL(5,2) '$.MaintenanceScore' + ) AS Metrics + WHERE Metrics.DateTime IS NOT NULL + ORDER BY Metrics.DateTime, MachineArr.MachineCode +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p9 + @json NVARCHAR(MAX) +AS +BEGIN + SELECT * FROM OPENJSON(@json, '$') with (name nvarchar(max) '$.Factory' AS JSON) +END; +GO + + +CREATE VIEW BABEL_5054_vu_prepare_v1 +AS + SELECT * FROM OPENJSON(N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + , '$') with (name nvarchar(max) '$.Factory' AS JSON); +GO + + +CREATE VIEW BABEL_5054_vu_prepare_v2 +AS + SELECT + ProductionID.PlantCode, + MachineArr.MachineCode, + MachineArr.MachineName, + Metrics.DateTime, + Metrics.OperationalStatus, + Metrics.CycleTime, + Metrics.ProductCount, + Metrics.PowerConsumption, + Metrics.OEEScore, + Metrics.MaintenanceScore + FROM OPENJSON(N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }') WITH ( + ProductionID NVARCHAR(MAX) '$.Factory.ProductionID' AS JSON, + MachineStatusArray NVARCHAR(MAX) '$.Factory.MachineStatusArray' AS JSON + ) AS Factory + OUTER APPLY OPENJSON(Factory.ProductionID) WITH ( + PlantCode VARCHAR(10) '$.PlantCode' + ) AS ProductionID + OUTER APPLY OPENJSON(Factory.MachineStatusArray) WITH ( + MachineStatus NVARCHAR(MAX) '$.MachineStatus' AS JSON + ) AS Machines + OUTER APPLY OPENJSON(Machines.MachineStatus) WITH ( + MachineCode VARCHAR(10) '$.MachineCode', + MachineName VARCHAR(50) '$.MachineName', + HourlyMetricsArray NVARCHAR(MAX) '$.HourlyMetricsArray' AS JSON + ) AS MachineArr + OUTER APPLY OPENJSON(MachineArr.HourlyMetricsArray) WITH ( + HourlyMetrics NVARCHAR(MAX) '$.HourlyMetrics' AS JSON + ) AS HourlyData + OUTER APPLY OPENJSON(HourlyData.HourlyMetrics) WITH ( + DateTime DATETIME '$.DateTime', + OperationalStatus VARCHAR(20) '$.OperationalStatus', + CycleTime DECIMAL(10,2) '$.CycleTime', + ProductCount INT '$.ProductCount', + PowerConsumption DECIMAL(10,2) '$.PowerConsumption', + OEEScore DECIMAL(5,2) '$.OEEScore', + MaintenanceScore DECIMAL(5,2) '$.MaintenanceScore' + ) AS Metrics + WHERE Metrics.DateTime IS NOT NULL + ORDER BY Metrics.DateTime, MachineArr.MachineCode +GO diff --git a/test/JDBC/expected/BABEL-5054-vu-verify.out b/test/JDBC/expected/BABEL-5054-vu-verify.out new file mode 100644 index 0000000000..f719d21752 --- /dev/null +++ b/test/JDBC/expected/BABEL-5054-vu-verify.out @@ -0,0 +1,1087 @@ +-- Intermediate JSON result exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p1 +GO +~~START~~ +varchar#!#varchar#!#date#!#int#!#int#!#varchar#!#numeric#!#int +WHSE01#!#COLD#!#2023-01-03#!#400#!#100#!#true#!#-18.50#!#45 +WHSE01#!#COLD#!#2023-01-04#!#380#!#120#!#true#!#-18.20#!#44 +WHSE01#!#FRSH#!#2023-01-03#!#200#!#100#!#true#!#4.20#!#65 +WHSE01#!#HAZMT#!#2023-01-03#!#150#!#50#!#true#!#21.00#!#40 +~~END~~ + +DROP PROCEDURE BABEL_5054_vu_prepare_p1 +GO + +-- Intermediate JSON result exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p2 +GO +~~START~~ +varchar#!#varchar#!#varchar#!#datetime#!#varchar#!#numeric#!#int#!#numeric#!#numeric#!#numeric +MFGP01#!#CNC01#!#CNC Milling Station#!#2023-01-03 06:00:00.0#!#RUNNING#!#32.50#!#110#!#4.25#!#95.20#!#97.50 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 06:00:00.0#!#RUNNING#!#45.50#!#79#!#2.75#!#96.50#!#98.50 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 07:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 08:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 09:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 10:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 11:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +~~END~~ + +DROP PROCEDURE BABEL_5054_vu_prepare_p2 +GO + +-- Intermediate JSON result exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p3 +GO +~~START~~ +varchar#!#varchar#!#varchar#!#datetime#!#int#!#int#!#int#!#numeric#!#int#!#int#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar +MON20230103001#!#PT100123#!#ICD10-I21.0#!#2023-01-03 06:00:00.0#!#82#!#135#!#85#!#37.2#!#97#!#2#!#NORMAL#!#VEN001#!#VENTILATOR#!#RUNNING#!#NORMAL +MON20230103001#!#PT100124#!#ICD10-J18.9#!#2023-01-03 06:00:00.0#!#75#!#122#!#78#!#38.5#!#94#!#4#!#ELEVATED#!#INF001#!#INFUSION_PUMP#!#RUNNING#!#NORMAL +~~END~~ + +DROP PROCEDURE BABEL_5054_vu_prepare_p3 +GO + +-- JSON in a single result cell exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p4 +GO +~~START~~ +nvarchar +{"Factory": {"ProductionID": {"BatchEnd": "2023-01-03T14:00:00", "IsActive": "true", "PlantCode": "MFGP01", "ShiftCode": "SHIFT_A", "TimeStamp": "2023-01-03T00:00:00", "BatchStart": "2023-01-03T06:00:00", "QualityLevel": "PREMIUM", "SamplingRate": "60", "SupervisorID": "SUP_123", "MonitoringMode": "REAL_TIME", "ProductionLine": "LINE_001", "ProductCategories": "AUTOMOTIVE,ELECTRONICS", "CertificationLevel": "ISO9001", "ControlSystemVersion": "5.2.1"}, "SystemStatus": {"DataPoints": "1440", "LastBackup": "2023-01-02T23:00:00", "AlertStatus": "NORMAL", "SystemHealth": "OPTIMAL", "DataIntegrity": "99.98", "MonitoringPeriod": "28", "CalibrationStatus": "VALID", "MaintenanceWindow": "SCHEDULED"}, "QualityMetrics": {"ScrapRate": "0.3", "ReworkRate": "1.2", "FirstPassYield": "98.5", "BatchDefectRate": "0.14", "QualityAuditScore": "95.5", "CustomerComplaints": "0", "ProcessCapabilityIndex": "1.45"}, "MachineStatusArray": {"MachineStatus": [{"Zone": "ZONE_A", "InstallDate": "2022-01-15", "MachineCode": "ROB01", "MachineName": "Robotic Arm Assembly", "MachineType": "ROBOTICS", "LastMaintenance": "2022-12-15", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "96.5", "CycleTime": "45.5", "WearLevel": "15.5", "ErrorCount": "0", "OilPressure": "95.5", "RejectCount": "1", "ProductCount": "79", "QualityIndex": "99.5", "AccuracyScore": "99.8", "TargetCycleTime": "45.0", "MaintenanceScore": "98.5", "MotorTemperature": "42.5", "PerformanceIndex": "97.2", "PowerConsumption": "2.75", "VibrationReading": "0.12", "AvailabilityIndex": "99.8", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T07:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T08:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T09:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T10:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T11:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}]}, "CertificationExpiry": "2024-01-15"}, {"Zone": "ZONE_B", "InstallDate": "2021-06-20", "MachineCode": "CNC01", "MachineName": "CNC Milling Station", "MachineType": "CNC", "LastMaintenance": "2022-12-20", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "95.2", "ToolWear": "25.5", "CycleTime": "32.5", "ErrorCount": "0", "RejectCount": "2", "CoolantLevel": "92.5", "ProductCount": "110", "QualityIndex": "98.9", "AccuracyScore": "99.5", "SurfaceFinish": "0.8", "TargetCycleTime": "32.0", "MaintenanceScore": "97.5", "PerformanceIndex": "96.8", "PowerConsumption": "4.25", "AvailabilityIndex": "99.5", "OperationalStatus": "RUNNING", "SpindleTemperature": "55.5"}]}, "CertificationExpiry": "2024-06-20"}]}, "ResourceConsumption": {"WaterUsage": "850.2", "CompressedAir": "1200.5", "WasteGenerated": "45.5", "CarbonFootprint": "1250.75", "ElectricityUsage": "2750.5", "RawMaterialUsage": "2500.0", "RecycledMaterial": "40.2"}, "ProductionLineStatusArray": {"ProductionLineStatus": [{"DateTime": "2023-01-03T06:00:00", "DefectRate": "0.12", "NoiseLevel": "72.5", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "95.5", "QualityScore": "99.2", "HumidityZone1": "45", "HumidityZone2": "47", "ProductionRate": "857", "VibrationLevel": "0.15", "DowntimeMinutes": "0", "PressureReading": "101.3", "SafetyIncidents": "0", "TemperatureZone1": "22.5", "TemperatureZone2": "23.1", "EnergyConsumption": "450.75", "MaintenanceAlerts": "0", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.5"}, {"DateTime": "2023-01-03T07:00:00", "DefectRate": "0.15", "NoiseLevel": "73.1", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "97.2", "QualityScore": "99.1", "HumidityZone1": "46", "HumidityZone2": "48", "ProductionRate": "862", "VibrationLevel": "0.17", "DowntimeMinutes": "5", "PressureReading": "101.2", "SafetyIncidents": "0", "TemperatureZone1": "22.7", "TemperatureZone2": "23.3", "EnergyConsumption": "455.25", "MaintenanceAlerts": "1", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.2"}]}}} +~~END~~ + +DROP PROCEDURE BABEL_5054_vu_prepare_p4 +GO + +-- JSON in a single result cell exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p5 +GO +~~START~~ +nvarchar +{"Factory": {"ProductionID": {"BatchEnd": "2023-01-03T14:00:00", "IsActive": "true", "PlantCode": "MFGP01", "ShiftCode": "SHIFT_A", "TimeStamp": "2023-01-03T00:00:00", "BatchStart": "2023-01-03T06:00:00", "QualityLevel": "PREMIUM", "SamplingRate": "60", "SupervisorID": "SUP_123", "MonitoringMode": "REAL_TIME", "ProductionLine": "LINE_001", "ProductCategories": "AUTOMOTIVE,ELECTRONICS", "CertificationLevel": "ISO9001", "ControlSystemVersion": "5.2.1"}, "SystemStatus": {"DataPoints": "1440", "LastBackup": "2023-01-02T23:00:00", "AlertStatus": "NORMAL", "SystemHealth": "OPTIMAL", "DataIntegrity": "99.98", "MonitoringPeriod": "28", "CalibrationStatus": "VALID", "MaintenanceWindow": "SCHEDULED"}, "QualityMetrics": {"ScrapRate": "0.3", "ReworkRate": "1.2", "FirstPassYield": "98.5", "BatchDefectRate": "0.14", "QualityAuditScore": "95.5", "CustomerComplaints": "0", "ProcessCapabilityIndex": "1.45"}, "MachineStatusArray": {"MachineStatus": [{"Zone": "ZONE_A", "InstallDate": "2022-01-15", "MachineCode": "ROB01", "MachineName": "Robotic Arm Assembly", "MachineType": "ROBOTICS", "LastMaintenance": "2022-12-15", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "96.5", "CycleTime": "45.5", "WearLevel": "15.5", "ErrorCount": "0", "OilPressure": "95.5", "RejectCount": "1", "ProductCount": "79", "QualityIndex": "99.5", "AccuracyScore": "99.8", "TargetCycleTime": "45.0", "MaintenanceScore": "98.5", "MotorTemperature": "42.5", "PerformanceIndex": "97.2", "PowerConsumption": "2.75", "VibrationReading": "0.12", "AvailabilityIndex": "99.8", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T07:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T08:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T09:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T10:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T11:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}]}, "CertificationExpiry": "2024-01-15"}, {"Zone": "ZONE_B", "InstallDate": "2021-06-20", "MachineCode": "CNC01", "MachineName": "CNC Milling Station", "MachineType": "CNC", "LastMaintenance": "2022-12-20", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "95.2", "ToolWear": "25.5", "CycleTime": "32.5", "ErrorCount": "0", "RejectCount": "2", "CoolantLevel": "92.5", "ProductCount": "110", "QualityIndex": "98.9", "AccuracyScore": "99.5", "SurfaceFinish": "0.8", "TargetCycleTime": "32.0", "MaintenanceScore": "97.5", "PerformanceIndex": "96.8", "PowerConsumption": "4.25", "AvailabilityIndex": "99.5", "OperationalStatus": "RUNNING", "SpindleTemperature": "55.5"}]}, "CertificationExpiry": "2024-06-20"}]}, "ResourceConsumption": {"WaterUsage": "850.2", "CompressedAir": "1200.5", "WasteGenerated": "45.5", "CarbonFootprint": "1250.75", "ElectricityUsage": "2750.5", "RawMaterialUsage": "2500.0", "RecycledMaterial": "40.2"}, "ProductionLineStatusArray": {"ProductionLineStatus": [{"DateTime": "2023-01-03T06:00:00", "DefectRate": "0.12", "NoiseLevel": "72.5", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "95.5", "QualityScore": "99.2", "HumidityZone1": "45", "HumidityZone2": "47", "ProductionRate": "857", "VibrationLevel": "0.15", "DowntimeMinutes": "0", "PressureReading": "101.3", "SafetyIncidents": "0", "TemperatureZone1": "22.5", "TemperatureZone2": "23.1", "EnergyConsumption": "450.75", "MaintenanceAlerts": "0", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.5"}, {"DateTime": "2023-01-03T07:00:00", "DefectRate": "0.15", "NoiseLevel": "73.1", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "97.2", "QualityScore": "99.1", "HumidityZone1": "46", "HumidityZone2": "48", "ProductionRate": "862", "VibrationLevel": "0.17", "DowntimeMinutes": "5", "PressureReading": "101.2", "SafetyIncidents": "0", "TemperatureZone1": "22.7", "TemperatureZone2": "23.3", "EnergyConsumption": "455.25", "MaintenanceAlerts": "1", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.2"}]}}} +~~END~~ + +DROP PROCEDURE BABEL_5054_vu_prepare_p5 +GO + +-- JSON in a single result cell exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p6 +GO +~~START~~ +nvarchar +{"ProductionID": {"BatchEnd": "2023-01-03T14:00:00", "IsActive": "true", "PlantCode": "MFGP01", "ShiftCode": "SHIFT_A", "TimeStamp": "2023-01-03T00:00:00", "BatchStart": "2023-01-03T06:00:00", "QualityLevel": "PREMIUM", "SamplingRate": "60", "SupervisorID": "SUP_123", "MonitoringMode": "REAL_TIME", "ProductionLine": "LINE_001", "ProductCategories": "AUTOMOTIVE,ELECTRONICS", "CertificationLevel": "ISO9001", "ControlSystemVersion": "5.2.1"}, "SystemStatus": {"DataPoints": "1440", "LastBackup": "2023-01-02T23:00:00", "AlertStatus": "NORMAL", "SystemHealth": "OPTIMAL", "DataIntegrity": "99.98", "MonitoringPeriod": "28", "CalibrationStatus": "VALID", "MaintenanceWindow": "SCHEDULED"}, "QualityMetrics": {"ScrapRate": "0.3", "ReworkRate": "1.2", "FirstPassYield": "98.5", "BatchDefectRate": "0.14", "QualityAuditScore": "95.5", "CustomerComplaints": "0", "ProcessCapabilityIndex": "1.45"}, "MachineStatusArray": {"MachineStatus": [{"Zone": "ZONE_A", "InstallDate": "2022-01-15", "MachineCode": "ROB01", "MachineName": "Robotic Arm Assembly", "MachineType": "ROBOTICS", "LastMaintenance": "2022-12-15", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "96.5", "CycleTime": "45.5", "WearLevel": "15.5", "ErrorCount": "0", "OilPressure": "95.5", "RejectCount": "1", "ProductCount": "79", "QualityIndex": "99.5", "AccuracyScore": "99.8", "TargetCycleTime": "45.0", "MaintenanceScore": "98.5", "MotorTemperature": "42.5", "PerformanceIndex": "97.2", "PowerConsumption": "2.75", "VibrationReading": "0.12", "AvailabilityIndex": "99.8", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T07:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T08:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T09:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T10:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T11:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}]}, "CertificationExpiry": "2024-01-15"}, {"Zone": "ZONE_B", "InstallDate": "2021-06-20", "MachineCode": "CNC01", "MachineName": "CNC Milling Station", "MachineType": "CNC", "LastMaintenance": "2022-12-20", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "95.2", "ToolWear": "25.5", "CycleTime": "32.5", "ErrorCount": "0", "RejectCount": "2", "CoolantLevel": "92.5", "ProductCount": "110", "QualityIndex": "98.9", "AccuracyScore": "99.5", "SurfaceFinish": "0.8", "TargetCycleTime": "32.0", "MaintenanceScore": "97.5", "PerformanceIndex": "96.8", "PowerConsumption": "4.25", "AvailabilityIndex": "99.5", "OperationalStatus": "RUNNING", "SpindleTemperature": "55.5"}]}, "CertificationExpiry": "2024-06-20"}]}, "ResourceConsumption": {"WaterUsage": "850.2", "CompressedAir": "1200.5", "WasteGenerated": "45.5", "CarbonFootprint": "1250.75", "ElectricityUsage": "2750.5", "RawMaterialUsage": "2500.0", "RecycledMaterial": "40.2"}, "ProductionLineStatusArray": {"ProductionLineStatus": [{"DateTime": "2023-01-03T06:00:00", "DefectRate": "0.12", "NoiseLevel": "72.5", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "95.5", "QualityScore": "99.2", "HumidityZone1": "45", "HumidityZone2": "47", "ProductionRate": "857", "VibrationLevel": "0.15", "DowntimeMinutes": "0", "PressureReading": "101.3", "SafetyIncidents": "0", "TemperatureZone1": "22.5", "TemperatureZone2": "23.1", "EnergyConsumption": "450.75", "MaintenanceAlerts": "0", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.5"}, {"DateTime": "2023-01-03T07:00:00", "DefectRate": "0.15", "NoiseLevel": "73.1", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "97.2", "QualityScore": "99.1", "HumidityZone1": "46", "HumidityZone2": "48", "ProductionRate": "862", "VibrationLevel": "0.17", "DowntimeMinutes": "5", "PressureReading": "101.2", "SafetyIncidents": "0", "TemperatureZone1": "22.7", "TemperatureZone2": "23.3", "EnergyConsumption": "455.25", "MaintenanceAlerts": "1", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.2"}]}} +~~END~~ + +DROP PROCEDURE BABEL_5054_vu_prepare_p6 +GO + +-- long JSON exceeding 4000 characters as input +-- Expect no error +DECLARE @json NVARCHAR(MAX) = N'{ + "Warehouse": { + "WarehouseID": { + "ScanDate": "2023-01-03", + "FacilityCode": "WHSE01", + "InventoryType": "ProductType", + "ValidFrom": "2023-01-03", + "ValidTo": "2023-02-28", + "Zones": "ZONE_A,ZONE_B,ZONE_C", + "Sections": "SEC1,SEC2,SEC3", + "IsActive": "true", + "RequestMode": "STANDARD", + "MaxResults": "100", + "LocationID": "LOC123", + "TrackingEnabled": "true", + "BatchNumber": "BTH2023001", + "SensorID": "1234", + "ReadingID": "5678" + }, + "SystemMetadata": { + "TotalDays": "30", + "TotalRecords": "15", + "HasMoreRecords": "false", + "IsComplete": "true", + "LastUpdate": "2023-01-03T14:30:00", + "ProcessingTime": "1.5", + "DataQuality": "HIGH" + }, + "FacilityDailyStatusArray": { + "FacilityDailyStatus": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "100", + "MaintenanceSpace": "50", + "AvailableSpace": "800", + "AllocatedSpace": "100", + "TotalUsed": "200", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "8", + "OperationalHours": "24", + "PowerConsumption": "450.75", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-04", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-05", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-06", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-07", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-08", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-09", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-10", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + } + ] + }, + "StorageTypeArray": { + "StorageType": [ + { + "StorageCode": "COLD", + "StorageName": "Cold Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "false", + "Zone": "ZONE_A", + "MaxWeight": "5000", + "StorageClass": "CLASS_A", + "SecurityLevel": "HIGH", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "500", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "400", + "AllocatedSpace": "50", + "TotalUsed": "100", + "TotalCapacity": "500", + "Temperature": "-18.5", + "Humidity": "45", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-02-01", + "AlertCount": "0", + "DoorOpenCount": "24", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + }, + { + "Date": "2023-01-04", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "500", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "380", + "AllocatedSpace": "70", + "TotalUsed": "120", + "TotalCapacity": "500", + "Temperature": "-18.2", + "Humidity": "44", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-02-01", + "AlertCount": "1", + "DoorOpenCount": "28", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + } + ] + } + }, + { + "StorageCode": "FRSH", + "StorageName": "Fresh Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "false", + "Zone": "ZONE_B", + "MaxWeight": "3000", + "StorageClass": "CLASS_B", + "SecurityLevel": "MEDIUM", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "300", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "200", + "AllocatedSpace": "50", + "TotalUsed": "100", + "TotalCapacity": "300", + "Temperature": "4.2", + "Humidity": "65", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-02", + "NextMaintenance": "2023-02-02", + "AlertCount": "0", + "DoorOpenCount": "35", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + } + ] + } + }, + { + "StorageCode": "HAZMT", + "StorageName": "Hazmat Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "true", + "Zone": "ZONE_C", + "MaxWeight": "2000", + "StorageClass": "CLASS_H", + "SecurityLevel": "MAXIMUM", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "200", + "RestrictedAccess": "true", + "MinStaffing": "3", + "AvailableSpace": "150", + "AllocatedSpace": "30", + "TotalUsed": "50", + "TotalCapacity": "200", + "Temperature": "21.0", + "Humidity": "40", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-01-15", + "AlertCount": "0", + "DoorOpenCount": "12", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL", + "HazmatIncidents": "0", + "SafetyInspectionStatus": "PASSED", + "EmergencyResponseReady": "true" + } + ] + } + } + ] + }, + "EnvironmentalMetrics": { + "AirQuality": "GOOD", + "CO2Levels": "450", + "NoiseLevel": "65", + "LightingLevel": "800", + "WaterUsage": "1250", + "WasteManagement": "OPTIMAL", + "RecyclingRate": "85.5" + }, + "SecurityStatus": { + "AccessControlStatus": "ACTIVE", + "SecurityPersonnel": "4", + "CameraStatus": "OPERATIONAL", + "LastIncident": "2022-12-15", + "ThreatLevel": "LOW", + "PerimeterStatus": "SECURE" + } + } + }' +EXEC BABEL_5054_vu_prepare_p7 @jsonInventory = @json +GO +~~START~~ +varchar#!#varchar#!#date#!#int#!#int#!#varchar#!#numeric#!#int +WHSE01#!#COLD#!#2023-01-03#!#400#!#100#!#true#!#-18.50#!#45 +WHSE01#!#COLD#!#2023-01-04#!#380#!#120#!#true#!#-18.20#!#44 +WHSE01#!#FRSH#!#2023-01-03#!#200#!#100#!#true#!#4.20#!#65 +WHSE01#!#HAZMT#!#2023-01-03#!#150#!#50#!#true#!#21.00#!#40 +~~END~~ + +DROP PROCEDURE BABEL_5054_vu_prepare_p7 +GO + + +-- long JSON exceeding 4000 characters as input +-- Expect no error +DECLARE @json NVARCHAR(MAX) = N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' +EXEC BABEL_5054_vu_prepare_p8 @jsonProduction = @json +GO +~~START~~ +varchar#!#varchar#!#varchar#!#datetime#!#varchar#!#numeric#!#int#!#numeric#!#numeric#!#numeric +MFGP01#!#CNC01#!#CNC Milling Station#!#2023-01-03 06:00:00.0#!#RUNNING#!#32.50#!#110#!#4.25#!#95.20#!#97.50 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 06:00:00.0#!#RUNNING#!#45.50#!#79#!#2.75#!#96.50#!#98.50 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 07:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 08:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 09:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 10:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 11:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +~~END~~ + +DROP PROCEDURE BABEL_5054_vu_prepare_p8 +GO + + +-- long JSON exceeding 4000 characters as input +-- Expect no error +DECLARE @json NVARCHAR(MAX) = N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' +EXEC BABEL_5054_vu_prepare_p9 @json = @json +GO +~~START~~ +nvarchar +{"ProductionID": {"BatchEnd": "2023-01-03T14:00:00", "IsActive": "true", "PlantCode": "MFGP01", "ShiftCode": "SHIFT_A", "TimeStamp": "2023-01-03T00:00:00", "BatchStart": "2023-01-03T06:00:00", "QualityLevel": "PREMIUM", "SamplingRate": "60", "SupervisorID": "SUP_123", "MonitoringMode": "REAL_TIME", "ProductionLine": "LINE_001", "ProductCategories": "AUTOMOTIVE,ELECTRONICS", "CertificationLevel": "ISO9001", "ControlSystemVersion": "5.2.1"}, "SystemStatus": {"DataPoints": "1440", "LastBackup": "2023-01-02T23:00:00", "AlertStatus": "NORMAL", "SystemHealth": "OPTIMAL", "DataIntegrity": "99.98", "MonitoringPeriod": "28", "CalibrationStatus": "VALID", "MaintenanceWindow": "SCHEDULED"}, "QualityMetrics": {"ScrapRate": "0.3", "ReworkRate": "1.2", "FirstPassYield": "98.5", "BatchDefectRate": "0.14", "QualityAuditScore": "95.5", "CustomerComplaints": "0", "ProcessCapabilityIndex": "1.45"}, "MachineStatusArray": {"MachineStatus": [{"Zone": "ZONE_A", "InstallDate": "2022-01-15", "MachineCode": "ROB01", "MachineName": "Robotic Arm Assembly", "MachineType": "ROBOTICS", "LastMaintenance": "2022-12-15", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "96.5", "CycleTime": "45.5", "WearLevel": "15.5", "ErrorCount": "0", "OilPressure": "95.5", "RejectCount": "1", "ProductCount": "79", "QualityIndex": "99.5", "AccuracyScore": "99.8", "TargetCycleTime": "45.0", "MaintenanceScore": "98.5", "MotorTemperature": "42.5", "PerformanceIndex": "97.2", "PowerConsumption": "2.75", "VibrationReading": "0.12", "AvailabilityIndex": "99.8", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T07:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T08:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T09:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T10:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T11:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}]}, "CertificationExpiry": "2024-01-15"}, {"Zone": "ZONE_B", "InstallDate": "2021-06-20", "MachineCode": "CNC01", "MachineName": "CNC Milling Station", "MachineType": "CNC", "LastMaintenance": "2022-12-20", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "95.2", "ToolWear": "25.5", "CycleTime": "32.5", "ErrorCount": "0", "RejectCount": "2", "CoolantLevel": "92.5", "ProductCount": "110", "QualityIndex": "98.9", "AccuracyScore": "99.5", "SurfaceFinish": "0.8", "TargetCycleTime": "32.0", "MaintenanceScore": "97.5", "PerformanceIndex": "96.8", "PowerConsumption": "4.25", "AvailabilityIndex": "99.5", "OperationalStatus": "RUNNING", "SpindleTemperature": "55.5"}]}, "CertificationExpiry": "2024-06-20"}]}, "ResourceConsumption": {"WaterUsage": "850.2", "CompressedAir": "1200.5", "WasteGenerated": "45.5", "CarbonFootprint": "1250.75", "ElectricityUsage": "2750.5", "RawMaterialUsage": "2500.0", "RecycledMaterial": "40.2"}, "ProductionLineStatusArray": {"ProductionLineStatus": [{"DateTime": "2023-01-03T06:00:00", "DefectRate": "0.12", "NoiseLevel": "72.5", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "95.5", "QualityScore": "99.2", "HumidityZone1": "45", "HumidityZone2": "47", "ProductionRate": "857", "VibrationLevel": "0.15", "DowntimeMinutes": "0", "PressureReading": "101.3", "SafetyIncidents": "0", "TemperatureZone1": "22.5", "TemperatureZone2": "23.1", "EnergyConsumption": "450.75", "MaintenanceAlerts": "0", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.5"}, {"DateTime": "2023-01-03T07:00:00", "DefectRate": "0.15", "NoiseLevel": "73.1", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "97.2", "QualityScore": "99.1", "HumidityZone1": "46", "HumidityZone2": "48", "ProductionRate": "862", "VibrationLevel": "0.17", "DowntimeMinutes": "5", "PressureReading": "101.2", "SafetyIncidents": "0", "TemperatureZone1": "22.7", "TemperatureZone2": "23.3", "EnergyConsumption": "455.25", "MaintenanceAlerts": "1", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.2"}]}} +~~END~~ + +DROP PROCEDURE BABEL_5054_vu_prepare_p9 +GO + + +-- long JSON exceeding 4000 characters in create view +-- Expect no error +SELECT * FROM BABEL_5054_vu_prepare_v1 +GO +~~START~~ +nvarchar +{"ProductionID": {"BatchEnd": "2023-01-03T14:00:00", "IsActive": "true", "PlantCode": "MFGP01", "ShiftCode": "SHIFT_A", "TimeStamp": "2023-01-03T00:00:00", "BatchStart": "2023-01-03T06:00:00", "QualityLevel": "PREMIUM", "SamplingRate": "60", "SupervisorID": "SUP_123", "MonitoringMode": "REAL_TIME", "ProductionLine": "LINE_001", "ProductCategories": "AUTOMOTIVE,ELECTRONICS", "CertificationLevel": "ISO9001", "ControlSystemVersion": "5.2.1"}, "SystemStatus": {"DataPoints": "1440", "LastBackup": "2023-01-02T23:00:00", "AlertStatus": "NORMAL", "SystemHealth": "OPTIMAL", "DataIntegrity": "99.98", "MonitoringPeriod": "28", "CalibrationStatus": "VALID", "MaintenanceWindow": "SCHEDULED"}, "QualityMetrics": {"ScrapRate": "0.3", "ReworkRate": "1.2", "FirstPassYield": "98.5", "BatchDefectRate": "0.14", "QualityAuditScore": "95.5", "CustomerComplaints": "0", "ProcessCapabilityIndex": "1.45"}, "MachineStatusArray": {"MachineStatus": [{"Zone": "ZONE_A", "InstallDate": "2022-01-15", "MachineCode": "ROB01", "MachineName": "Robotic Arm Assembly", "MachineType": "ROBOTICS", "LastMaintenance": "2022-12-15", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "96.5", "CycleTime": "45.5", "WearLevel": "15.5", "ErrorCount": "0", "OilPressure": "95.5", "RejectCount": "1", "ProductCount": "79", "QualityIndex": "99.5", "AccuracyScore": "99.8", "TargetCycleTime": "45.0", "MaintenanceScore": "98.5", "MotorTemperature": "42.5", "PerformanceIndex": "97.2", "PowerConsumption": "2.75", "VibrationReading": "0.12", "AvailabilityIndex": "99.8", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T07:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T08:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T09:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T10:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}, {"DateTime": "2023-01-03T11:00:00", "OEEScore": "95.8", "CycleTime": "45.8", "WearLevel": "15.7", "ErrorCount": "1", "OilPressure": "95.2", "RejectCount": "2", "ProductCount": "77", "QualityIndex": "99.3", "AccuracyScore": "99.7", "TargetCycleTime": "45.0", "MaintenanceScore": "98.2", "MotorTemperature": "43.1", "PerformanceIndex": "96.8", "PowerConsumption": "2.82", "VibrationReading": "0.14", "AvailabilityIndex": "99.7", "OperationalStatus": "RUNNING"}]}, "CertificationExpiry": "2024-01-15"}, {"Zone": "ZONE_B", "InstallDate": "2021-06-20", "MachineCode": "CNC01", "MachineName": "CNC Milling Station", "MachineType": "CNC", "LastMaintenance": "2022-12-20", "HourlyMetricsArray": {"HourlyMetrics": [{"DateTime": "2023-01-03T06:00:00", "OEEScore": "95.2", "ToolWear": "25.5", "CycleTime": "32.5", "ErrorCount": "0", "RejectCount": "2", "CoolantLevel": "92.5", "ProductCount": "110", "QualityIndex": "98.9", "AccuracyScore": "99.5", "SurfaceFinish": "0.8", "TargetCycleTime": "32.0", "MaintenanceScore": "97.5", "PerformanceIndex": "96.8", "PowerConsumption": "4.25", "AvailabilityIndex": "99.5", "OperationalStatus": "RUNNING", "SpindleTemperature": "55.5"}]}, "CertificationExpiry": "2024-06-20"}]}, "ResourceConsumption": {"WaterUsage": "850.2", "CompressedAir": "1200.5", "WasteGenerated": "45.5", "CarbonFootprint": "1250.75", "ElectricityUsage": "2750.5", "RawMaterialUsage": "2500.0", "RecycledMaterial": "40.2"}, "ProductionLineStatusArray": {"ProductionLineStatus": [{"DateTime": "2023-01-03T06:00:00", "DefectRate": "0.12", "NoiseLevel": "72.5", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "95.5", "QualityScore": "99.2", "HumidityZone1": "45", "HumidityZone2": "47", "ProductionRate": "857", "VibrationLevel": "0.15", "DowntimeMinutes": "0", "PressureReading": "101.3", "SafetyIncidents": "0", "TemperatureZone1": "22.5", "TemperatureZone2": "23.1", "EnergyConsumption": "450.75", "MaintenanceAlerts": "0", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.5"}, {"DateTime": "2023-01-03T07:00:00", "DefectRate": "0.15", "NoiseLevel": "73.1", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "97.2", "QualityScore": "99.1", "HumidityZone1": "46", "HumidityZone2": "48", "ProductionRate": "862", "VibrationLevel": "0.17", "DowntimeMinutes": "5", "PressureReading": "101.2", "SafetyIncidents": "0", "TemperatureZone1": "22.7", "TemperatureZone2": "23.3", "EnergyConsumption": "455.25", "MaintenanceAlerts": "1", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.2"}, {"DateTime": "2023-01-03T08:00:00", "DefectRate": "0.15", "NoiseLevel": "73.1", "TargetSpeed": "100.0", "WorkerCount": "12", "CurrentSpeed": "97.2", "QualityScore": "99.1", "HumidityZone1": "46", "HumidityZone2": "48", "ProductionRate": "862", "VibrationLevel": "0.17", "DowntimeMinutes": "5", "PressureReading": "101.2", "SafetyIncidents": "0", "TemperatureZone1": "22.7", "TemperatureZone2": "23.3", "EnergyConsumption": "455.25", "MaintenanceAlerts": "1", "OperationalStatus": "RUNNING", "MaterialEfficiency": "98.2"}]}} +~~END~~ + +DROP VIEW BABEL_5054_vu_prepare_v1 +GO + + +-- long JSON exceeding 4000 characters in create view +-- Expect no error +SELECT * FROM BABEL_5054_vu_prepare_v2 +GO +~~START~~ +varchar#!#varchar#!#varchar#!#datetime#!#varchar#!#numeric#!#int#!#numeric#!#numeric#!#numeric +MFGP01#!#CNC01#!#CNC Milling Station#!#2023-01-03 06:00:00.0#!#RUNNING#!#32.50#!#110#!#4.25#!#95.20#!#97.50 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 06:00:00.0#!#RUNNING#!#45.50#!#79#!#2.75#!#96.50#!#98.50 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 07:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 08:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 09:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 10:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +MFGP01#!#ROB01#!#Robotic Arm Assembly#!#2023-01-03 11:00:00.0#!#RUNNING#!#45.80#!#77#!#2.82#!#95.80#!#98.20 +~~END~~ + +DROP VIEW BABEL_5054_vu_prepare_v2 +GO diff --git a/test/JDBC/expected/BABEL-5242-union-tsql-basetype.out b/test/JDBC/expected/BABEL-5242-union-tsql-basetype.out new file mode 100644 index 0000000000..a63e738884 --- /dev/null +++ b/test/JDBC/expected/BABEL-5242-union-tsql-basetype.out @@ -0,0 +1,543 @@ +-- +-- Tests on the result data type should retain as tsql base type after UNION +-- +CREATE TABLE t1 ( + a INT, + TransactionAmount money NULL +); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 't1' + AND a.[name] = 'TransactionAmount'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +CREATE VIEW TestView AS + select + traamo = a + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- The result data type should retain as money +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + SELECT CASE 2 + WHEN 1 THEN a + WHEN 2 THEN TransactionAmount + END AS traamo + FROM t1; +GO + + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = null + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- The result data type should retain as money +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = CAST(null AS money) + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = CAST(11 AS NUMERIC) + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- Result data type after UNION between numeric and money should be numeric +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +numeric#!#numeric +~~END~~ + + +DROP VIEW TestView; +GO + +DROP TABLE t1; +GO + +CREATE TABLE t1 ( + a smallmoney, + b money, + c text, + d numeric, + e int +); +GO + +INSERT INTO t1 VALUES (214748.3647, 922337203685477.5807, 'test', 1.2, 4), (-214748.3648, -922337203685477.5808, 'test', 2.3, 4); +GO +~~ROW COUNT: 2~~ + + +CREATE view TestView as + select + traamo = a + from t1 +union all + select + traamo = b + from t1 +union all + select traamo = CAST(214748.3657 AS MONEY); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +SELECT * FROM TestView ORDER BY traamo; +GO +~~START~~ +money +-922337203685477.5808 +-214748.3648 +214748.3647 +214748.3657 +922337203685477.5807 +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE view TestView as + select + traamo = b + from t1 +union all + select + traamo = a + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +money#!#money +~~END~~ + + +DROP VIEW TestView; +GO + +-- Coercion error should be raised +SELECT a FROM t1 +UNION +SELECT b FROM t1 +UNION +SELECT c FROM t1; +GO +~~START~~ +money +~~ERROR (Code: 293)~~ + +~~ERROR (Message: invalid characters found: cannot cast value "test" to money)~~ + + +CREATE view TestView as + select + traamo = a + from t1 +union all + select + traamo = b + from t1 +union all + select + traamo = d + from t1 +union all + select + traamo = e + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +numeric#!#numeric +~~END~~ + + +DROP VIEW TestView; +GO + +DROP TABLE t1; +GO + +CREATE TABLE ti ( + a tinyint, + b smallint +); +GO + +CREATE VIEW TestView AS + select + traamo = a + from ti +union all + select + traamo = null + from ti; +GO + +-- Should be tinyint instead of smallint +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +tinyint#!#tinyint +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = a + from ti +union all + select + traamo = b + from ti; +GO + +-- Should be smallint since UNION between tinyint and smallint +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +smallint#!#smallint +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = b + from ti +union all + select + traamo = a + from ti; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +smallint#!#smallint +~~END~~ + + +INSERT INTO ti VALUES (255, 256), (0, -1); +GO +~~ROW COUNT: 2~~ + + +SELECT * FROM TestView ORDER BY traamo; +GO +~~START~~ +smallint +-1 +0 +255 +256 +~~END~~ + + + +DROP VIEW TestView; +DROP TABLE ti; +GO + +-- Involving user-defined type in T-SQL, result after UNION should be the base type +CREATE TYPE SSN FROM VARCHAR(11) NOT NULL; +GO + +CREATE TABLE tn (a VARCHAR(11) NOT NULL, b SSN); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'tn' + AND a.[name] = 'b'; +GO +~~START~~ +varchar#!#nvarchar +ssn#!#ssn +~~END~~ + + +CREATE VIEW TestView AS + select + traamo = 'hope' + from tn +union all + select + traamo = b + from tn; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +varchar#!#varchar +~~END~~ + + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = a + from tn +union all + select + traamo = b + from tn; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO +~~START~~ +varchar#!#nvarchar +varchar#!#varchar +~~END~~ + + +DROP VIEW TestView; +GO + +DROP TABLE tn; +GO + +DROP TYPE SSN; +GO + +CREATE TYPE BABEL_CASE_EXPR_TEST_UDT FROM NVARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'ةيسايق - ليجستلا ةقاطب' AS NTEXT) +END AS RESULT +GO +~~START~~ +ntext +ةيسايق - ليجستلا ةقاطب +~~END~~ + + +DROP TYPE BABEL_CASE_EXPR_TEST_UDT; +GO + +-- Coercion error should be raised +SELECT 'unknown' +UNION +SELECT $1.0 +UNION +SELECT N'xyz'; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: invalid input syntax for type numeric: "unknown")~~ + diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index d162a5a3e5..7cbd7d9bfb 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,8 +10436,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -?????–?? +ntext +登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,8 +10968,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -?????–?? +ntext +登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out index 76e7e954ca..3d2606ea2b 100644 --- a/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/BABEL-CASE_EXPR-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,8 +10436,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -?????–?? +ntext +登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,8 +10968,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -?????–?? +ntext +登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/BABEL-EXTENDEDPROPERTY-vu-verify.out b/test/JDBC/expected/BABEL-EXTENDEDPROPERTY-vu-verify.out index b7b369cc30..32f6f345ba 100644 --- a/test/JDBC/expected/BABEL-EXTENDEDPROPERTY-vu-verify.out +++ b/test/JDBC/expected/BABEL-EXTENDEDPROPERTY-vu-verify.out @@ -72,6 +72,25 @@ TYPE#!#babel_extended_property_v3_type#!#type property1#!#type property1 before ~~END~~ +-- BABEL-5087 +EXEC sp_addextendedproperty + @name = N'MS_Description', + @level0type = N'SCHEMA', + @level0name = N'babel_extended_property_v3_schema', + @level1type = N'table', + @level1name = N'babel_extended_property_v3_table'; +GO + +SELECT * FROM fn_listextendedproperty(NULL, 'SCHEMA', N'babel_extended_property_v3_schema', 'TABLE', N'babel_extended_property_v3_table', NULL, NULL); +GO +~~START~~ +varchar#!#varchar#!#varchar#!#sql_variant +TABLE#!#babel_extended_property_v3_table#!#MS_Description#!# +TABLE#!#babel_extended_property_v3_table#!#table property1#!#table property1 value +TABLE#!#babel_extended_property_v3_table#!#table property2#!#table property2 value +~~END~~ + + -- list all extended properties SELECT class, class_desc, IIF(major_id > 0, 1, 0) AS major_id, minor_id, name, value FROM sys.extended_properties ORDER BY class, class_desc, name, value; GO @@ -81,6 +100,7 @@ tinyint#!#nvarchar#!#int#!#int#!#varchar#!#sql_variant 1#!#OBJECT_OR_COLUMN#!#1#!#1#!#column property1#!#column property1 value 1#!#OBJECT_OR_COLUMN#!#1#!#1#!#COLUMN PROPERTY2 "{\)#!#COLUMN PROPERTY2 VALUE "{\) 1#!#OBJECT_OR_COLUMN#!#1#!#0#!#function property1#!#function property1 value +1#!#OBJECT_OR_COLUMN#!#1#!#0#!#MS_Description#!# 1#!#OBJECT_OR_COLUMN#!#1#!#0#!#procedure property1#!#procedure property1 value 1#!#OBJECT_OR_COLUMN#!#1#!#0#!#sequence property1#!#sequence property1 value 1#!#OBJECT_OR_COLUMN#!#1#!#0#!#table property1#!#table property1 value diff --git a/test/JDBC/expected/BABEL-VERSION.out b/test/JDBC/expected/BABEL-VERSION.out index 7ca1548352..251095a397 100644 --- a/test/JDBC/expected/BABEL-VERSION.out +++ b/test/JDBC/expected/BABEL-VERSION.out @@ -280,14 +280,14 @@ GO ~~WARNING (Message: babelfishpg_tds.product_version cannot be set. Please enter 4 valid numbers separated by '.' Server SQLState: 01000)~~ -ALTER DATABASE jdbc_testdb SET babelfishpg_tsql.version = "test"; +ALTER DATABASE babelfish_db SET babelfishpg_tsql.version = "test"; GO ~~WARNING (Code: 0)~~ ~~WARNING (Message: Product version setting by babelfishpg_tds.product_version GUC will have no effect on @@VERSION Server SQLState: 01000)~~ -ALTER DATABASE jdbc_testdb SET babelfishpg_tsql.version = "default"; +ALTER DATABASE babelfish_db SET babelfishpg_tsql.version = "default"; GO Alter system set babelfishpg_tds.product_version = "16.4.3000.6"; diff --git a/test/JDBC/expected/TestBasicInterop.out b/test/JDBC/expected/TestBasicInterop.out index 55a1fe3a25..f5ce27a05b 100644 --- a/test/JDBC/expected/TestBasicInterop.out +++ b/test/JDBC/expected/TestBasicInterop.out @@ -186,3 +186,31 @@ GO -- psql DROP PROCEDURE pg_interop_proc_sp_exec GO + +-- tsql +CREATE TABLE babel_5446 (Test INT NULL) +GO +INSERT INTO babel_5446 SELECT ISNUMERIC('test') AS my_isnumeric +GO +~~ROW COUNT: 1~~ + +SELECT @@trancount +GO +~~START~~ +int +0 +~~END~~ + + +INSERT INTO babel_5446 SELECT ISNUMERIC('test') AS my_isnumeric +SELECT @@trancount +GO +~~ROW COUNT: 1~~ + +~~START~~ +int +0 +~~END~~ + +DROP TABLE babel_5446 +GO diff --git a/test/JDBC/expected/alter_table.out b/test/JDBC/expected/alter_table.out index 786f1934c4..3811693f05 100644 --- a/test/JDBC/expected/alter_table.out +++ b/test/JDBC/expected/alter_table.out @@ -70,3 +70,36 @@ GO drop table trans2 GO + +--------------------------- BABEL-5417 --------------------------- +------- DROP COLUMN SHOULD NOT DROP TRIGGERS ON THE TABLE -------- +CREATE TABLE babel_5417(a int, b int); +GO +CREATE TRIGGER babel_5417_trg +ON babel_5417 +AFTER INSERT AS SELECT 1 +GO +SELECT tgname FROM pg_trigger WHERE tgname LIKE 'babel_5417%'; +GO +~~START~~ +varchar +babel_5417_trg +~~END~~ + +ALTER TABLE babel_5417 DROP COLUMN a +GO +SELECT tgname FROM pg_trigger WHERE tgname LIKE 'babel_5417%'; +GO +~~START~~ +varchar +babel_5417_trg +~~END~~ + +DROP TABLE babel_5417 +GO +SELECT tgname FROM pg_trigger WHERE tgname LIKE 'babel_5417%'; +GO +~~START~~ +varchar +~~END~~ + diff --git a/test/JDBC/expected/datepart-vu-cleanup.out b/test/JDBC/expected/datepart-vu-cleanup.out index f4d1180298..54deb8b343 100644 --- a/test/JDBC/expected/datepart-vu-cleanup.out +++ b/test/JDBC/expected/datepart-vu-cleanup.out @@ -18,3 +18,6 @@ GO DROP PROCEDURE date_part_vu_prepare_sys_day_proc GO + +DROP TABLE date_part_vu_prepare_TestDates, date_part_vu_prepare_TestTimezones, date_part_vu_prepare_TestResults, date_part_vu_prepare_DateParts; +GO diff --git a/test/JDBC/expected/datepart-vu-prepare.out b/test/JDBC/expected/datepart-vu-prepare.out index 03f7c603cb..307a381169 100644 --- a/test/JDBC/expected/datepart-vu-prepare.out +++ b/test/JDBC/expected/datepart-vu-prepare.out @@ -43,3 +43,47 @@ CREATE PROCEDURE date_part_vu_prepare_sys_day_proc @a datetime AS SELECT DAY(@a) GO + +-- Test Case for Date Part Functions Timezone Invariance +CREATE TABLE date_part_vu_prepare_DateParts (DatePartName VARCHAR(20)); +GO +CREATE TABLE date_part_vu_prepare_TestDates ( + TestDateTime DATETIME, + TestDateTimeOffset DATETIMEOFFSET, + TestDateTime2 DATETIME2, + TestSmallDateTime SMALLDATETIME +); +GO +CREATE TABLE date_part_vu_prepare_TestTimezones (TimezoneName VARCHAR(50)); +GO +CREATE TABLE date_part_vu_prepare_TestResults ( + TestCase VARCHAR(100), + TimeZone VARCHAR(50), + DataType VARCHAR(20), + InputDate VARCHAR(50), + DatePart VARCHAR(20), + DatePartValue SQL_VARIANT, + DateName NVARCHAR(100) +); +GO + +-- -- Populate tables +INSERT INTO date_part_vu_prepare_DateParts (DatePartName) VALUES +('year'), ('quarter'), ('month'), ('dayofyear'), ('day'), +('week'), ('weekday'), ('hour'), ('minute'), ('second'), +('millisecond'), ('microsecond'), ('nanosecond'), +('tzoffset'), ('iso_week'); +GO +~~ROW COUNT: 15~~ + +INSERT INTO date_part_vu_prepare_TestDates VALUES +('2025-01-01 05:30:45', '2025-01-01 05:30:45 +00:00', '2025-01-01 05:30:45.1234567', '2025-01-01 05:31:00'), +('2025-06-15 23:59:59', '2025-06-15 23:59:59 +00:00', '2025-06-15 23:59:59.9876543', '2025-06-15 23:59:00'); +GO +~~ROW COUNT: 2~~ + +INSERT INTO date_part_vu_prepare_TestTimezones (TimezoneName) VALUES +('UTC'),('America/New_York'), ('Europe/London'), ('Asia/Tokyo'), ('Africa/Nairobi'); +GO +~~ROW COUNT: 5~~ + diff --git a/test/JDBC/expected/datepart-vu-verify.out b/test/JDBC/expected/datepart-vu-verify.out index fa8207a917..ef4a04490a 100644 --- a/test/JDBC/expected/datepart-vu-verify.out +++ b/test/JDBC/expected/datepart-vu-verify.out @@ -505,3 +505,1948 @@ int 2022 ~~END~~ + + + + + + + + + + + + + + + + + +-- Test Case for Date Part Functions Timezone Invariance +DECLARE @timezone VARCHAR(50); +DECLARE @datepart VARCHAR(20); +DECLARE @datatype VARCHAR(20); +DECLARE @datecol VARCHAR(30); +DECLARE @testdate DATETIME; +DECLARE @sql NVARCHAR(MAX); +-- Cursor for timezones +DECLARE timezone_cursor CURSOR FOR SELECT TimezoneName FROM date_part_vu_prepare_TestTimezones; +OPEN timezone_cursor; +FETCH NEXT FROM timezone_cursor INTO @timezone; +WHILE @@FETCH_STATUS = 0 +BEGIN + -- Set the timezone + EXEC('SELECT set_config(''timezone'', ''' + @timezone + ''', false)'); + -- Cursor for date parts + DECLARE datepart_cursor CURSOR FOR SELECT DatePartName FROM date_part_vu_prepare_DateParts; + OPEN datepart_cursor; + FETCH NEXT FROM datepart_cursor INTO @datepart; + WHILE @@FETCH_STATUS = 0 + BEGIN + -- Cursor for data types + DECLARE datatype_cursor CURSOR FOR + SELECT 'DATETIME', 'TestDateTime' UNION ALL + SELECT 'DATETIMEOFFSET', 'TestDateTimeOffset' UNION ALL + SELECT 'DATETIME2', 'TestDateTime2' UNION ALL + SELECT 'SMALLDATETIME', 'TestSmallDateTime'; + OPEN datatype_cursor; + FETCH NEXT FROM datatype_cursor INTO @datatype, @datecol; + WHILE @@FETCH_STATUS = 0 + BEGIN + -- Cursor for test dates + DECLARE testdate_cursor CURSOR FOR SELECT TestDateTime FROM date_part_vu_prepare_TestDates; + OPEN testdate_cursor; + FETCH NEXT FROM testdate_cursor INTO @testdate; + WHILE @@FETCH_STATUS = 0 + BEGIN + SET @sql = N' + INSERT INTO date_part_vu_prepare_TestResults (TestCase, TimeZone, DataType, InputDate, DatePart, DatePartValue, DateName) + SELECT + ''Test: '' + CONVERT(VARCHAR, ' + @datecol + ', 120) + '' in ' + @timezone + ''' AS TestCase, + ''' + @timezone + ''' AS TimeZone, + ''' + @datatype + ''' AS DataType, + CONVERT(VARCHAR, ' + @datecol + ', 120) AS InputDate, + ''' + @datepart + ''' AS DatePart, + DATEPART(' + @datepart + ', ' + @datecol + ') AS DatePartValue, + DATENAME(' + @datepart + ', ' + @datecol + ') AS DateName + FROM date_part_vu_prepare_TestDates + WHERE TestDateTime = ''' + CONVERT(VARCHAR, @testdate, 120) + ''''; + EXEC sp_executesql @sql; + FETCH NEXT FROM testdate_cursor INTO @testdate; + END + CLOSE testdate_cursor; + DEALLOCATE testdate_cursor; + FETCH NEXT FROM datatype_cursor INTO @datatype, @datecol; + END + CLOSE datatype_cursor; + DEALLOCATE datatype_cursor; + FETCH NEXT FROM datepart_cursor INTO @datepart; + END + CLOSE datepart_cursor; + DEALLOCATE datepart_cursor; + FETCH NEXT FROM timezone_cursor INTO @timezone; +END +CLOSE timezone_cursor; +DEALLOCATE timezone_cursor; +GO +~~START~~ +text +UTC +~~END~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~START~~ +text +America/New_York +~~END~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~START~~ +text +Europe/London +~~END~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~START~~ +text +Asia/Tokyo +~~END~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~START~~ +text +Africa/Nairobi +~~END~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + +~~ROW COUNT: 1~~ + + +-- Analyze results +SELECT * FROM date_part_vu_prepare_TestResults +ORDER BY DataType, InputDate, TimeZone, DatePart; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#sql_variant#!#nvarchar +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-01-01 05:30:45#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 in America/New_York#!#America/New_York#!#DATETIME#!#2025-01-01 05:30:45#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-01-01 05:30:45#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 in Europe/London#!#Europe/London#!#DATETIME#!#2025-01-01 05:30:45#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 in UTC#!#UTC#!#DATETIME#!#2025-01-01 05:30:45#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME#!#2025-06-15 23:59:59#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 in America/New_York#!#America/New_York#!#DATETIME#!#2025-06-15 23:59:59#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME#!#2025-06-15 23:59:59#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 in Europe/London#!#Europe/London#!#DATETIME#!#2025-06-15 23:59:59#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 in UTC#!#UTC#!#DATETIME#!#2025-06-15 23:59:59#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#microsecond#!#123457#!#123457 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#millisecond#!#123#!#123 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#month#!#1#!#January +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#nanosecond#!#123457000#!#123457000 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45.123457 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#microsecond#!#123457#!#123457 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#millisecond#!#123#!#123 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#month#!#1#!#January +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#nanosecond#!#123457000#!#123457000 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45.123457 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#microsecond#!#123457#!#123457 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#millisecond#!#123#!#123 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#month#!#1#!#January +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#nanosecond#!#123457000#!#123457000 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45.123457 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#microsecond#!#123457#!#123457 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#millisecond#!#123#!#123 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#month#!#1#!#January +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#nanosecond#!#123457000#!#123457000 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45.123457 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#microsecond#!#123457#!#123457 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#millisecond#!#123#!#123 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#month#!#1#!#January +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#nanosecond#!#123457000#!#123457000 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45.123457 in UTC#!#UTC#!#DATETIME2#!#2025-01-01 05:30:45.123457#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#microsecond#!#987654#!#987654 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#millisecond#!#987#!#987 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#month#!#6#!#June +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#nanosecond#!#987654000#!#987654000 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59.987654 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#microsecond#!#987654#!#987654 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#millisecond#!#987#!#987 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#month#!#6#!#June +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#nanosecond#!#987654000#!#987654000 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59.987654 in America/New_York#!#America/New_York#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#microsecond#!#987654#!#987654 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#millisecond#!#987#!#987 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#month#!#6#!#June +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#nanosecond#!#987654000#!#987654000 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59.987654 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#microsecond#!#987654#!#987654 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#millisecond#!#987#!#987 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#month#!#6#!#June +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#nanosecond#!#987654000#!#987654000 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59.987654 in Europe/London#!#Europe/London#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#microsecond#!#987654#!#987654 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#millisecond#!#987#!#987 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#month#!#6#!#June +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#nanosecond#!#987654000#!#987654000 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59.987654 in UTC#!#UTC#!#DATETIME2#!#2025-06-15 23:59:59.987654#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#year#!#2025#!#2025 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#day#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#minute#!#30#!#30 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#month#!#1#!#January +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#second#!#45#!#45 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#week#!#1#!#1 +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:30:45 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-01-01 05:30:45 +00:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 +00:00 in Africa/Nairobi#!#Africa/Nairobi#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 +00:00 in America/New_York#!#America/New_York#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 +00:00 in Asia/Tokyo#!#Asia/Tokyo#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 +00:00 in Europe/London#!#Europe/London#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#second#!#59#!#59 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:59 +00:00 in UTC#!#UTC#!#DATETIMEOFFSET#!#2025-06-15 23:59:59 +00:00#!#year#!#2025#!#2025 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#day#!#1#!#1 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#minute#!#31#!#31 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#month#!#1#!#January +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#second#!#0#!#0 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#week#!#1#!#1 +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:31:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#year#!#2025#!#2025 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#day#!#1#!#1 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#minute#!#31#!#31 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#month#!#1#!#January +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#second#!#0#!#0 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#week#!#1#!#1 +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:31:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#year#!#2025#!#2025 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#day#!#1#!#1 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#minute#!#31#!#31 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#month#!#1#!#January +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#second#!#0#!#0 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#week#!#1#!#1 +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:31:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#year#!#2025#!#2025 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#day#!#1#!#1 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#minute#!#31#!#31 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#month#!#1#!#January +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#second#!#0#!#0 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#week#!#1#!#1 +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:31:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#year#!#2025#!#2025 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#day#!#1#!#1 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#dayofyear#!#1#!#1 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#hour#!#5#!#5 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#iso_week#!#1#!#1 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#microsecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#millisecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#minute#!#31#!#31 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#month#!#1#!#January +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#nanosecond#!#0#!#0 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#quarter#!#1#!#1 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#second#!#0#!#0 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#tzoffset#!#0#!#0 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#week#!#1#!#1 +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#weekday#!#4#!#Wednesday +Test: 2025-01-01 05:31:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-01-01 05:31:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#second#!#0#!#0 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:00 in Africa/Nairobi#!#Africa/Nairobi#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#second#!#0#!#0 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:00 in America/New_York#!#America/New_York#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#second#!#0#!#0 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:00 in Asia/Tokyo#!#Asia/Tokyo#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#second#!#0#!#0 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:00 in Europe/London#!#Europe/London#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#year#!#2025#!#2025 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#day#!#15#!#15 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#dayofyear#!#166#!#166 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#hour#!#23#!#23 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#iso_week#!#24#!#24 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#microsecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#millisecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#minute#!#59#!#59 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#month#!#6#!#June +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#nanosecond#!#0#!#0 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#quarter#!#2#!#2 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#second#!#0#!#0 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#tzoffset#!#0#!#0 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#week#!#25#!#25 +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#weekday#!#1#!#Sunday +Test: 2025-06-15 23:59:00 in UTC#!#UTC#!#SMALLDATETIME#!#2025-06-15 23:59:00#!#year#!#2025#!#2025 +~~END~~ + + +-- Check for any discrepancies +SELECT + DataType, + InputDate, + DatePart, + COUNT(DISTINCT DatePartValue) AS UniqueDatePartValues, + COUNT(DISTINCT DateName) AS UniqueDateNames +FROM date_part_vu_prepare_TestResults +GROUP BY DataType, InputDate, DatePart +HAVING + COUNT(DISTINCT DatePartValue) > 1 OR + COUNT(DISTINCT DateName) > 1; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#int#!#int +~~END~~ + + +-- Reset Timezone +SELECT set_config('timezone', 'UTC', false) +GO +~~START~~ +text +UTC +~~END~~ + diff --git a/test/JDBC/expected/db_accessadmin-vu-verify.out b/test/JDBC/expected/db_accessadmin-vu-verify.out index 1e8e987be1..fda5e04f78 100644 --- a/test/JDBC/expected/db_accessadmin-vu-verify.out +++ b/test/JDBC/expected/db_accessadmin-vu-verify.out @@ -570,13 +570,13 @@ CREATE SCHEMA babel_5136_s1 GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ CREATE SCHEMA babel_5136_s1 AUTHORIZATION babel_5136_u1 GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ -- Should not be able to drop a database DROP DATABASE babel_5136 diff --git a/test/JDBC/expected/db_ddladmin-vu-verify.out b/test/JDBC/expected/db_ddladmin-vu-verify.out index 925135f186..97de538271 100644 --- a/test/JDBC/expected/db_ddladmin-vu-verify.out +++ b/test/JDBC/expected/db_ddladmin-vu-verify.out @@ -134,13 +134,13 @@ CREATE SCHEMA babel_5116_sch1 GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ CREATE SCHEMA babel_5116_sch1 AUTHORIZATION babel_5116_r1 GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ CREATE PARTITION FUNCTION babel_5116_pf1 (datetime) diff --git a/test/JDBC/expected/db_owner-vu-verify.out b/test/JDBC/expected/db_owner-vu-verify.out index f4a0263cf1..8c2aef4b0e 100644 --- a/test/JDBC/expected/db_owner-vu-verify.out +++ b/test/JDBC/expected/db_owner-vu-verify.out @@ -305,16 +305,6 @@ go alter procedure dbo.dbowner__p0 as select 20 go --- BABEL-5417: Trigger gets dropped if we drop a column in table -create trigger dbo.dbowner__trg0 -on dbo.dbowner__t0 -after insert -as -begin - select 'New row inserted' -end -go - -- Member of db_owner role should be allowed to rename objects exec sp_rename 'dbo.dbowner__t0.x', 'x_renamed', 'column' go diff --git a/test/JDBC/expected/dbcreator_role-vu-verify.out b/test/JDBC/expected/dbcreator_role-vu-verify.out index 4dc8d7d2fb..cd3efe781a 100644 --- a/test/JDBC/expected/dbcreator_role-vu-verify.out +++ b/test/JDBC/expected/dbcreator_role-vu-verify.out @@ -691,7 +691,7 @@ create schema perm_denied_scm go ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ create view perm_denied_v1 as select 1; diff --git a/test/JDBC/expected/latest__verification_cleanup__13_5__bbf_view_def-vu-verify.out b/test/JDBC/expected/latest__verification_cleanup__13_5__bbf_view_def-vu-verify.out index 39753e1909..2aa57736da 100644 --- a/test/JDBC/expected/latest__verification_cleanup__13_5__bbf_view_def-vu-verify.out +++ b/test/JDBC/expected/latest__verification_cleanup__13_5__bbf_view_def-vu-verify.out @@ -9,8 +9,8 @@ SELECT * FROM bbf_view_def_upgrade_vu_prepare_dep_view WHERE "TABLE_NAME" LIKE ' GO ~~START~~ varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#varchar -jdbc_testdb#!#master_dbo#!#bbf_view_def_upgrade_vu_prepare_dep_view#!##!#NONE#!#NO#!#NO#!#NO#!#NO#!#NO -jdbc_testdb#!#master_dbo#!#bbf_view_def_upgrade_vu_prepare_view#!##!#NONE#!#NO#!#NO#!#NO#!#NO#!#NO +babelfish_db#!#master_dbo#!#bbf_view_def_upgrade_vu_prepare_dep_view#!##!#NONE#!#NO#!#NO#!#NO#!#NO#!#NO +babelfish_db#!#master_dbo#!#bbf_view_def_upgrade_vu_prepare_view#!##!#NONE#!#NO#!#NO#!#NO#!#NO#!#NO ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-3392-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-3392-vu-verify.out index f873655520..bd6041dd04 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-3392-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-3392-vu-verify.out @@ -1637,7 +1637,7 @@ SELECT name, max_length FROM sys.columns WHERE name = 'babel4157_c1' GO ~~START~~ varchar#!#smallint -babel4157_c1#!# +babel4157_c1#!#3 ~~END~~ @@ -1890,14 +1890,14 @@ select cast(17 as varbinary(1)) UNION select cast(10 as varbinary(2)) union sele GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type "nchar" to bbf_varbinary)~~ +~~ERROR (Message: UNION could not convert type "nchar" to varbinary)~~ SELECT CAST(N'ΘЖऌฒ' AS NCHAR(15)) UNION select cast(10 as varbinary(2)); GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type varbinary to bpchar)~~ +~~ERROR (Message: UNION could not convert type varbinary to "nchar")~~ SELECT CAST(1 as BIT) UNION SELECT cast(N'ab' as NCHAR(10)) UNION SELECT CAST('bar' as CHAR(10)); diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index d311f1b907..48250a5087 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,7 +10436,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,7 +10968,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out index f0332904d4..8851f6b1a1 100644 --- a/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/chinese_prc_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,7 +10436,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,7 +10968,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-3392-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-3392-vu-verify.out index e7e8261699..b4c6b93aa3 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-3392-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-3392-vu-verify.out @@ -1637,7 +1637,7 @@ SELECT name, max_length FROM sys.columns WHERE name = 'babel4157_c1' GO ~~START~~ varchar#!#smallint -babel4157_c1#!# +babel4157_c1#!#3 ~~END~~ @@ -1890,14 +1890,14 @@ select cast(17 as varbinary(1)) UNION select cast(10 as varbinary(2)) union sele GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type "nchar" to bbf_varbinary)~~ +~~ERROR (Message: UNION could not convert type "nchar" to varbinary)~~ SELECT CAST(N'ΘЖऌฒ' AS NCHAR(15)) UNION select cast(10 as varbinary(2)); GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: UNION could not convert type varbinary to bpchar)~~ +~~ERROR (Message: UNION could not convert type varbinary to "nchar")~~ SELECT CAST(1 as BIT) UNION SELECT cast(N'ab' as NCHAR(10)) UNION SELECT CAST('bar' as CHAR(10)); diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out index ad3b761a5b..3ac4829781 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-before-16_5-or-15_9-vu-verify.out @@ -403,7 +403,7 @@ nvarchar SELECT * FROM BABEL_5103_V2 GO ~~START~~ -varchar +nvarchar 登録カード ~~END~~ @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,8 +10436,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -登録カード?標準 +ntext +登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,8 +10968,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -登録カード?標準 +ntext +登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out index 3e7235a458..3ac4829781 100644 --- a/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out +++ b/test/JDBC/expected/non_default_server_collation/japanese_ci_as/BABEL-CASE_EXPR-vu-verify.out @@ -5375,7 +5375,7 @@ SELECT CASE 'abcd' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -5388,8 +5388,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE japanese_ci_as END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5414,8 +5414,8 @@ SELECT CASE N'بطاقة التسجيل - قياسية' COLLATE CHINESE_PRC_CI_A END AS RESULT GO ~~START~~ -varchar -????? ??????? - ?????? +nvarchar +بطاقة التسجيل - قياسية ~~END~~ @@ -5427,8 +5427,8 @@ SELECT CASE N' abc🙂defghi🙂🙂 ' COLLATE CHINESE_PRC_CI_AS END AS RESULT GO ~~START~~ -varchar - abc?defghi?? +nvarchar + abc🙂defghi🙂🙂 ~~END~~ @@ -5440,7 +5440,7 @@ SELECT CASE 'abcd' COLLATE ARABIC_CI_AS END AS RESULT GO ~~START~~ -varchar +nvarchar abcd ~~END~~ @@ -9993,7 +9993,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10046,7 +10046,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10171,7 +10171,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10224,7 +10224,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10277,7 +10277,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10330,7 +10330,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10383,8 +10383,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10436,8 +10436,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -登録カード?標準 +ntext +登録カード–標準 ~~END~~ @@ -10504,7 +10504,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -10572,7 +10572,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x12345600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~~END~~ @@ -10703,7 +10703,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10756,7 +10756,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10809,7 +10809,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ @@ -10862,7 +10862,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext char1 ~~END~~ @@ -10915,8 +10915,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -????? ??????? - ?????? +ntext +بطاقة التسجيل - قياسية ~~END~~ @@ -10968,8 +10968,8 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text -登録カード?標準 +ntext +登録カード–標準 ~~END~~ @@ -11036,7 +11036,7 @@ SELECT CASE 1 END AS RESULT GO ~~START~~ -text +ntext abc ~~END~~ @@ -11104,7 +11104,7 @@ SELECT CASE 2 END AS RESULT GO ~~START~~ -text +ntext 0x123456 ~~END~~ diff --git a/test/JDBC/expected/ownership_restrictions_from_pg_su_user.out b/test/JDBC/expected/ownership_restrictions_from_pg_su_user.out index efca534e76..a1f9ab9696 100644 --- a/test/JDBC/expected/ownership_restrictions_from_pg_su_user.out +++ b/test/JDBC/expected/ownership_restrictions_from_pg_su_user.out @@ -1,7 +1,7 @@ -- tsql -- This test file checks the changes which are ignored in the tod run -- As tod will not be able to create an SUPERUSER --- and testing on jdbc_testdb(where bbf is initialized) is not possible +-- and testing on babelfish_db(where bbf is initialized) is not possible CREATE LOGIN ownership_restrictions_from_pg_login1 WITH password = '12345678'; GO @@ -22,7 +22,7 @@ GO -- If tsql login connected through psql Alter ROLE of an bbf created logins/user/roles for password, -- connection limit and valid until should be working fine -- and the rest of alter role operations should throw an error. -ALTER ROLE ALL IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE ALL IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -30,7 +30,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE master_ownership_restrictions_from_pg_role1 IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE master_ownership_restrictions_from_pg_role1 IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -38,7 +38,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE CURRENT_ROLE IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE CURRENT_ROLE IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -46,7 +46,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE CURRENT_USER IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE CURRENT_USER IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -54,7 +54,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE SESSION_USER IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE SESSION_USER IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -62,7 +62,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE ownership_restrictions_from_pg_login1 IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE ownership_restrictions_from_pg_login1 IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -74,7 +74,7 @@ GO -- For plain psql user Alter ROLE of an bbf created logins/user/roles for password, -- connection limit and valid until should be working fine -- and the rest of alter role operations should throw an error. -ALTER ROLE ALL IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE ALL IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -82,7 +82,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE master_ownership_restrictions_from_pg_role1 IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE master_ownership_restrictions_from_pg_role1 IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -90,7 +90,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE CURRENT_ROLE IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE CURRENT_ROLE IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -98,7 +98,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE CURRENT_USER IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE CURRENT_USER IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -106,7 +106,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE SESSION_USER IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE SESSION_USER IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ @@ -114,7 +114,7 @@ GO Server SQLState: 42501)~~ -ALTER ROLE ownership_restrictions_from_pg_login1 IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE ownership_restrictions_from_pg_login1 IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO ~~ERROR (Code: 0)~~ diff --git a/test/JDBC/expected/securityadmin_role-vu-verify.out b/test/JDBC/expected/securityadmin_role-vu-verify.out index 42557e6c5b..ccabd5967a 100644 --- a/test/JDBC/expected/securityadmin_role-vu-verify.out +++ b/test/JDBC/expected/securityadmin_role-vu-verify.out @@ -801,7 +801,7 @@ create schema perm_denied_scm go ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ create view perm_denied_v1 as select 1; diff --git a/test/JDBC/expected/single_db/db_accessadmin-vu-verify.out b/test/JDBC/expected/single_db/db_accessadmin-vu-verify.out index 0d74c5c76e..1d6984ce2c 100644 --- a/test/JDBC/expected/single_db/db_accessadmin-vu-verify.out +++ b/test/JDBC/expected/single_db/db_accessadmin-vu-verify.out @@ -570,13 +570,13 @@ CREATE SCHEMA babel_5136_s1 GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ CREATE SCHEMA babel_5136_s1 AUTHORIZATION babel_5136_u1 GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ -- Should not be able to drop a database DROP DATABASE babel_5136 diff --git a/test/JDBC/expected/single_db/db_ddladmin-vu-verify.out b/test/JDBC/expected/single_db/db_ddladmin-vu-verify.out index 16ff7b1ffb..20fc8f95b5 100644 --- a/test/JDBC/expected/single_db/db_ddladmin-vu-verify.out +++ b/test/JDBC/expected/single_db/db_ddladmin-vu-verify.out @@ -134,13 +134,13 @@ CREATE SCHEMA babel_5116_sch1 GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ CREATE SCHEMA babel_5116_sch1 AUTHORIZATION babel_5116_r1 GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ CREATE PARTITION FUNCTION babel_5116_pf1 (datetime) diff --git a/test/JDBC/expected/single_db/dbcreator_role-vu-verify.out b/test/JDBC/expected/single_db/dbcreator_role-vu-verify.out index 44b8c5d57e..00b27faa19 100644 --- a/test/JDBC/expected/single_db/dbcreator_role-vu-verify.out +++ b/test/JDBC/expected/single_db/dbcreator_role-vu-verify.out @@ -690,7 +690,7 @@ create schema perm_denied_scm go ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: permission denied for database jdbc_testdb)~~ +~~ERROR (Message: permission denied for database babelfish_db)~~ create view perm_denied_v1 as select 1; diff --git a/test/JDBC/expected/temp_table.out b/test/JDBC/expected/temp_table.out index 3a65d23ee7..7de7719c7a 100644 --- a/test/JDBC/expected/temp_table.out +++ b/test/JDBC/expected/temp_table.out @@ -1,3 +1,6 @@ +USE master +GO + -- BABEL-4912 test ALTER TABLE for temp tables CREATE TABLE #t1 (a INT IDENTITY PRIMARY KEY NOT NULL, b INT) GO @@ -258,3 +261,210 @@ int DROP TABLE #t1 GO + +-- BABEL-4868 disallow the usage of user-defined functions in temp table column defaults (to prevent orphaned catalog entries) +CREATE FUNCTION temp_table_func1(@a INT) RETURNS INT AS BEGIN RETURN 1 END +GO + +-- normal tables should be ok +CREATE TABLE temp_table_t1(a INT DEFAULT temp_table_func1(5)) +GO + +INSERT INTO temp_table_t1 VALUES (DEFAULT) +GO +~~ROW COUNT: 1~~ + + +SELECT * FROM temp_table_t1 +GO +~~START~~ +int +1 +~~END~~ + + +DROP TABLE temp_table_t1 +GO + +-- temp tables should not work +CREATE TABLE #t1 (a INT DEFAULT temp_table_func1(5)) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: User-defined functions, partition functions, and column references are not allowed in expressions in this context.)~~ + + +-- two and three part names should not work either +CREATE TABLE #t1 (a INT DEFAULT dbo.temp_table_func1(6)) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Column "master_dbo" is not allowed in this context, and the user-defined function or aggregate "master_dbo.temp_table_func1" could not be found.)~~ + + +CREATE TABLE #t1 (a INT DEFAULT master.dbo.temp_table_func1(7)) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Column "master_dbo" is not allowed in this context, and the user-defined function or aggregate "master_dbo.temp_table_func1" could not be found.)~~ + + +-- also block adding columns via ALTER TABLE +CREATE TABLE #t1 (a INT) +GO + +ALTER TABLE #t1 ADD b INT DEFAULT temp_table_func1(5) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: User-defined functions, partition functions, and column references are not allowed in expressions in this context.)~~ + + +DROP TABLE #t1 +GO + +-- same with table variables +DECLARE @tv TABLE (a INT DEFAULT temp_table_func1(5)) +INSERT INTO @tv VALUES (DEFAULT) +SELECT * FROM @tv +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: User-defined functions, partition functions, and column references are not allowed in expressions in this context.)~~ + + +-- system functions such as ISJSON() should work +CREATE TABLE #t1 (a INT DEFAULT ISJSON('a')) +GO + +ALTER TABLE #t1 ADD b INT DEFAULT ISJSON('b') +GO + +INSERT INTO #t1 VALUES (DEFAULT, DEFAULT) +GO +~~ROW COUNT: 1~~ + + +SELECT * FROM #t1 +GO +~~START~~ +int#!#int +0#!#0 +~~END~~ + + +DROP TABLE #t1 +GO + +DECLARE @tv TABLE (a INT DEFAULT ISJSON('a')) +INSERT INTO @tv VALUES (DEFAULT) +SELECT * FROM @tv +GO +~~ROW COUNT: 1~~ + +~~START~~ +int +0 +~~END~~ + + +-- disallow "sys"-qualified function calls +CREATE TABLE #t1 (a INT DEFAULT SYS.ISJSON('a')) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Column "sys" is not allowed in this context, and the user-defined function or aggregate "sys.isjson" could not be found.)~~ + + +-- disallow user-defined overrides for system functions +CREATE FUNCTION ISJSON(@json TEXT) RETURNS INT AS BEGIN RETURN 10 END +GO + +-- cannot use schema-qualified name +CREATE TABLE #t1 (a INT DEFAULT dbo.ISJSON('a')) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Column "master_dbo" is not allowed in this context, and the user-defined function or aggregate "master_dbo.isjson" could not be found.)~~ + + +-- should work, default to using the system function +CREATE TABLE #t1 (a INT DEFAULT ISJSON('a')) +GO + +INSERT INTO #t1 VALUES (DEFAULT) +GO +~~ROW COUNT: 1~~ + + +SELECT * FROM #t1 +GO +~~START~~ +int +0 +~~END~~ + + +DROP TABLE #t1 +GO + +-- Aggregate functions should not work +create table #t1(a int, b int default any_value(a)) +go +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: User-defined functions, partition functions, and column references are not allowed in expressions in this context.)~~ + + +create table #t1(a int, b int default any_value(1)) +go +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: User-defined functions, partition functions, and column references are not allowed in expressions in this context.)~~ + + +-- also validate that the restrictions work for ALTER TABLE ADD CONSTRAINT +CREATE TABLE #t1 (a INT) +GO + +-- user-defined functions should not work +ALTER TABLE #t1 ADD CONSTRAINT myconstraint DEFAULT temp_table_func1(5) FOR a +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: User-defined functions, partition functions, and column references are not allowed in expressions in this context.)~~ + + +-- nor should system function overrides +ALTER TABLE #t1 ADD CONSTRAINT myconstraint DEFAULT dbo.ISJSON('a') FOR a +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Column "master_dbo" is not allowed in this context, and the user-defined function or aggregate "master_dbo.isjson" could not be found.)~~ + + +-- but system functions should still work +ALTER TABLE #t1 ADD CONSTRAINT myconstraint DEFAULT ISJSON('a') FOR a +GO + +INSERT INTO #t1 VALUES (DEFAULT) +GO +~~ROW COUNT: 1~~ + + +SELECT * FROM #t1 +GO +~~START~~ +int +0 +~~END~~ + + +DROP TABLE #t1 +GO + +DROP FUNCTION dbo.ISJSON +GO + +DROP FUNCTION temp_table_func1 +GO diff --git a/test/JDBC/init.sh b/test/JDBC/init.sh index 60554309c1..337aded529 100755 --- a/test/JDBC/init.sh +++ b/test/JDBC/init.sh @@ -22,17 +22,17 @@ if [[ $parallel_query_mode = false ]]; then echo "============================== CREATING USER AND DATABASE ==============================" psql -U "$USER" -d postgres -a << EOF CREATE USER jdbc_user WITH SUPERUSER CREATEDB CREATEROLE PASSWORD '12345678' INHERIT; -DROP DATABASE IF EXISTS jdbc_testdb; -CREATE DATABASE jdbc_testdb OWNER jdbc_user; -\c jdbc_testdb +DROP DATABASE IF EXISTS babelfish_db; +CREATE DATABASE babelfish_db OWNER jdbc_user; +\c babelfish_db CREATE EXTENSION IF NOT EXISTS "babelfishpg_tds" CASCADE; GRANT ALL ON SCHEMA sys to jdbc_user; ALTER USER jdbc_user CREATEDB; -\c jdbc_testdb -ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb'; +\c babelfish_db +ALTER SYSTEM SET babelfishpg_tsql.database_name = 'babelfish_db'; ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db'; SELECT pg_reload_conf(); -\c jdbc_testdb +\c babelfish_db show babelfishpg_tsql.database_name; CALL sys.initialize_babelfish('jdbc_user'); EOF @@ -44,14 +44,14 @@ if [[ $parallel_query_mode = true ]]; then echo "============================== CREATING USER AND DATABASE ==============================" psql -U "$USER" -d postgres -a << EOF CREATE USER jdbc_user WITH SUPERUSER CREATEDB CREATEROLE PASSWORD '12345678' INHERIT; -DROP DATABASE IF EXISTS jdbc_testdb; -CREATE DATABASE jdbc_testdb OWNER jdbc_user; -\c jdbc_testdb +DROP DATABASE IF EXISTS babelfish_db; +CREATE DATABASE babelfish_db OWNER jdbc_user; +\c babelfish_db CREATE EXTENSION IF NOT EXISTS "babelfishpg_tds" CASCADE; GRANT ALL ON SCHEMA sys to jdbc_user; ALTER USER jdbc_user CREATEDB; -\c jdbc_testdb -ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb'; +\c babelfish_db +ALTER SYSTEM SET babelfishpg_tsql.database_name = 'babelfish_db'; ALTER SYSTEM SET babelfishpg_tsql.migration_mode = 'multi-db'; ALTER SYSTEM SET parallel_setup_cost = 0; ALTER SYSTEM SET parallel_tuple_cost = 0; @@ -60,7 +60,7 @@ ALTER SYSTEM SET min_parallel_table_scan_size = 0; ALTER SYSTEM SET debug_parallel_query = 1; ALTER SYSTEM SET max_parallel_workers_per_gather = 4; SELECT pg_reload_conf(); -\c jdbc_testdb +\c babelfish_db show babelfishpg_tsql.database_name; CALL sys.initialize_babelfish('jdbc_user'); EOF diff --git a/test/JDBC/input/BABEL-5242-union-tsql-basetype.sql b/test/JDBC/input/BABEL-5242-union-tsql-basetype.sql new file mode 100644 index 0000000000..eb241f61da --- /dev/null +++ b/test/JDBC/input/BABEL-5242-union-tsql-basetype.sql @@ -0,0 +1,432 @@ +-- +-- Tests on the result data type should retain as tsql base type after UNION +-- +CREATE TABLE t1 ( + a INT, + TransactionAmount money NULL +); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 't1' + AND a.[name] = 'TransactionAmount'; +GO + +CREATE VIEW TestView AS + select + traamo = a + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- The result data type should retain as money +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + SELECT CASE 2 + WHEN 1 THEN a + WHEN 2 THEN TransactionAmount + END AS traamo + FROM t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; + +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = null + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- The result data type should retain as money +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = CAST(null AS money) + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = CAST(11 AS NUMERIC) + from t1 +union all + select + traamo = TransactionAmount + from t1; +GO + +-- Result data type after UNION between numeric and money should be numeric +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +DROP TABLE t1; +GO + +CREATE TABLE t1 ( + a smallmoney, + b money, + c text, + d numeric, + e int +); +GO + +INSERT INTO t1 VALUES (214748.3647, 922337203685477.5807, 'test', 1.2, 4), (-214748.3648, -922337203685477.5808, 'test', 2.3, 4); +GO + +CREATE view TestView as + select + traamo = a + from t1 +union all + select + traamo = b + from t1 +union all + select traamo = CAST(214748.3657 AS MONEY); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +SELECT * FROM TestView ORDER BY traamo; +GO + +DROP VIEW TestView; +GO + +CREATE view TestView as + select + traamo = b + from t1 +union all + select + traamo = a + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +-- Coercion error should be raised +SELECT a FROM t1 +UNION +SELECT b FROM t1 +UNION +SELECT c FROM t1; +GO + +CREATE view TestView as + select + traamo = a + from t1 +union all + select + traamo = b + from t1 +union all + select + traamo = d + from t1 +union all + select + traamo = e + from t1; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +DROP TABLE t1; +GO + +CREATE TABLE ti ( + a tinyint, + b smallint +); +GO + +CREATE VIEW TestView AS + select + traamo = a + from ti +union all + select + traamo = null + from ti; +GO + +-- Should be tinyint instead of smallint +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = a + from ti +union all + select + traamo = b + from ti; +GO + +-- Should be smallint since UNION between tinyint and smallint +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = b + from ti +union all + select + traamo = a + from ti; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +INSERT INTO ti VALUES (255, 256), (0, -1); +GO + +SELECT * FROM TestView ORDER BY traamo; +GO + +DROP VIEW TestView; + +DROP TABLE ti; +GO + +-- Involving user-defined type in T-SQL, result after UNION should be the base type +CREATE TYPE SSN FROM VARCHAR(11) NOT NULL; +GO + +CREATE TABLE tn (a VARCHAR(11) NOT NULL, b SSN); +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'tn' + AND a.[name] = 'b'; +GO + +CREATE VIEW TestView AS + select + traamo = 'hope' + from tn +union all + select + traamo = b + from tn; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +CREATE VIEW TestView AS + select + traamo = a + from tn +union all + select + traamo = b + from tn; +GO + +SELECT c.[name] AS [sys_types_user_type_id], + TYPE_NAME(a.user_type_id) AS type_name_function_user_type_id +FROM sys.columns a + INNER JOIN sys.objects b + ON a.[object_id] = b.[object_id] + LEFT JOIN sys.types c + ON a.user_type_id = c.user_type_id +WHERE b.[name] = 'TestView' + AND a.[name] = 'traamo'; +GO + +DROP VIEW TestView; +GO + +DROP TABLE tn; +GO + +DROP TYPE SSN; +GO + +CREATE TYPE BABEL_CASE_EXPR_TEST_UDT FROM NVARCHAR(100); +GO + +SELECT CASE 2 + WHEN 1 THEN CAST(0x123456 AS BABEL_CASE_EXPR_TEST_UDT) + WHEN 2 THEN CAST(N'ةيسايق - ليجستلا ةقاطب' AS NTEXT) +END AS RESULT +GO + +DROP TYPE BABEL_CASE_EXPR_TEST_UDT; +GO + +-- Coercion error should be raised +SELECT 'unknown' +UNION +SELECT $1.0 +UNION +SELECT N'xyz'; +GO diff --git a/test/JDBC/input/BABEL-EXTENDEDPROPERTY-vu-verify.sql b/test/JDBC/input/BABEL-EXTENDEDPROPERTY-vu-verify.sql index 711e4680c0..59f64a1bb7 100644 --- a/test/JDBC/input/BABEL-EXTENDEDPROPERTY-vu-verify.sql +++ b/test/JDBC/input/BABEL-EXTENDEDPROPERTY-vu-verify.sql @@ -25,6 +25,18 @@ GO SELECT * FROM fn_listextendedproperty(NULL, 'schema', 'babel_extended_property_v3_schema', 'type', NULL, NULL, NULL) ORDER BY objtype, objname, name, value; GO +-- BABEL-5087 +EXEC sp_addextendedproperty + @name = N'MS_Description', + @level0type = N'SCHEMA', + @level0name = N'babel_extended_property_v3_schema', + @level1type = N'table', + @level1name = N'babel_extended_property_v3_table'; +GO + +SELECT * FROM fn_listextendedproperty(NULL, 'SCHEMA', N'babel_extended_property_v3_schema', 'TABLE', N'babel_extended_property_v3_table', NULL, NULL); +GO + -- list all extended properties SELECT class, class_desc, IIF(major_id > 0, 1, 0) AS major_id, minor_id, name, value FROM sys.extended_properties ORDER BY class, class_desc, name, value; GO diff --git a/test/JDBC/input/BABEL-VERSION.mix b/test/JDBC/input/BABEL-VERSION.mix index 4592fad74d..aa61b3249c 100644 --- a/test/JDBC/input/BABEL-VERSION.mix +++ b/test/JDBC/input/BABEL-VERSION.mix @@ -84,10 +84,10 @@ GO Alter system set babelfishpg_tds.product_version = " "; GO -ALTER DATABASE jdbc_testdb SET babelfishpg_tsql.version = "test"; +ALTER DATABASE babelfish_db SET babelfishpg_tsql.version = "test"; GO -ALTER DATABASE jdbc_testdb SET babelfishpg_tsql.version = "default"; +ALTER DATABASE babelfish_db SET babelfishpg_tsql.version = "default"; GO Alter system set babelfishpg_tds.product_version = "16.4.3000.6"; diff --git a/test/JDBC/input/alter_table.sql b/test/JDBC/input/alter_table.sql index 8b97d57b32..4451aa1137 100644 --- a/test/JDBC/input/alter_table.sql +++ b/test/JDBC/input/alter_table.sql @@ -43,4 +43,25 @@ ALTER TABLE trans2 DROP COLUMN AddDate GO drop table trans2 -GO \ No newline at end of file +GO + +--------------------------- BABEL-5417 --------------------------- +------- DROP COLUMN SHOULD NOT DROP TRIGGERS ON THE TABLE -------- +CREATE TABLE babel_5417(a int, b int); +GO +CREATE TRIGGER babel_5417_trg +ON babel_5417 +AFTER INSERT AS SELECT 1 +GO +SELECT tgname FROM pg_trigger WHERE tgname LIKE 'babel_5417%'; +GO +ALTER TABLE babel_5417 DROP COLUMN a +GO +SELECT tgname FROM pg_trigger WHERE tgname LIKE 'babel_5417%'; +GO +DROP TABLE babel_5417 +GO +SELECT tgname FROM pg_trigger WHERE tgname LIKE 'babel_5417%'; +GO +------------------------------------------------------------------ +------------------------------------------------------------------ diff --git a/test/JDBC/input/db_owner-vu-verify.mix b/test/JDBC/input/db_owner-vu-verify.mix index 81deed2762..33e2cf9536 100644 --- a/test/JDBC/input/db_owner-vu-verify.mix +++ b/test/JDBC/input/db_owner-vu-verify.mix @@ -135,16 +135,6 @@ go alter procedure dbo.dbowner__p0 as select 20 go --- BABEL-5417: Trigger gets dropped if we drop a column in table -create trigger dbo.dbowner__trg0 -on dbo.dbowner__t0 -after insert -as -begin - select 'New row inserted' -end -go - -- Member of db_owner role should be allowed to rename objects exec sp_rename 'dbo.dbowner__t0.x', 'x_renamed', 'column' go diff --git a/test/JDBC/input/functions/datepart-vu-cleanup.sql b/test/JDBC/input/functions/datepart-vu-cleanup.sql index f4d1180298..a4b1f88cc4 100644 --- a/test/JDBC/input/functions/datepart-vu-cleanup.sql +++ b/test/JDBC/input/functions/datepart-vu-cleanup.sql @@ -18,3 +18,6 @@ GO DROP PROCEDURE date_part_vu_prepare_sys_day_proc GO + +DROP TABLE date_part_vu_prepare_TestDates, date_part_vu_prepare_TestTimezones, date_part_vu_prepare_TestResults, date_part_vu_prepare_DateParts; +GO \ No newline at end of file diff --git a/test/JDBC/input/functions/datepart-vu-prepare.sql b/test/JDBC/input/functions/datepart-vu-prepare.sql index 03f7c603cb..c04fcadeed 100644 --- a/test/JDBC/input/functions/datepart-vu-prepare.sql +++ b/test/JDBC/input/functions/datepart-vu-prepare.sql @@ -43,3 +43,41 @@ CREATE PROCEDURE date_part_vu_prepare_sys_day_proc @a datetime AS SELECT DAY(@a) GO + +-- Test Case for Date Part Functions Timezone Invariance +CREATE TABLE date_part_vu_prepare_DateParts (DatePartName VARCHAR(20)); +GO +CREATE TABLE date_part_vu_prepare_TestDates ( + TestDateTime DATETIME, + TestDateTimeOffset DATETIMEOFFSET, + TestDateTime2 DATETIME2, + TestSmallDateTime SMALLDATETIME +); +GO +CREATE TABLE date_part_vu_prepare_TestTimezones (TimezoneName VARCHAR(50)); +GO +CREATE TABLE date_part_vu_prepare_TestResults ( + TestCase VARCHAR(100), + TimeZone VARCHAR(50), + DataType VARCHAR(20), + InputDate VARCHAR(50), + DatePart VARCHAR(20), + DatePartValue SQL_VARIANT, + DateName NVARCHAR(100) +); +GO + +-- -- Populate tables +INSERT INTO date_part_vu_prepare_DateParts (DatePartName) VALUES +('year'), ('quarter'), ('month'), ('dayofyear'), ('day'), +('week'), ('weekday'), ('hour'), ('minute'), ('second'), +('millisecond'), ('microsecond'), ('nanosecond'), +('tzoffset'), ('iso_week'); +GO +INSERT INTO date_part_vu_prepare_TestDates VALUES +('2025-01-01 05:30:45', '2025-01-01 05:30:45 +00:00', '2025-01-01 05:30:45.1234567', '2025-01-01 05:31:00'), +('2025-06-15 23:59:59', '2025-06-15 23:59:59 +00:00', '2025-06-15 23:59:59.9876543', '2025-06-15 23:59:00'); +GO +INSERT INTO date_part_vu_prepare_TestTimezones (TimezoneName) VALUES +('UTC'),('America/New_York'), ('Europe/London'), ('Asia/Tokyo'), ('Africa/Nairobi'); +GO \ No newline at end of file diff --git a/test/JDBC/input/functions/datepart-vu-verify.sql b/test/JDBC/input/functions/datepart-vu-verify.sql index 071dd08349..bb05e0582b 100644 --- a/test/JDBC/input/functions/datepart-vu-verify.sql +++ b/test/JDBC/input/functions/datepart-vu-verify.sql @@ -1,3 +1,4 @@ +-- sla_for_parallel_query_enforced 60000 SELECT DATEPART(dd, '07-18-2022') GO @@ -210,3 +211,110 @@ GO SELECT DATEPART(yy, '220101 14:30:00.97531086 +13:14') GO + + +-- Test Case for Date Part Functions Timezone Invariance +DECLARE @timezone VARCHAR(50); +DECLARE @datepart VARCHAR(20); +DECLARE @datatype VARCHAR(20); +DECLARE @datecol VARCHAR(30); +DECLARE @testdate DATETIME; +DECLARE @sql NVARCHAR(MAX); + +-- Cursor for timezones +DECLARE timezone_cursor CURSOR FOR SELECT TimezoneName FROM date_part_vu_prepare_TestTimezones; +OPEN timezone_cursor; +FETCH NEXT FROM timezone_cursor INTO @timezone; + +WHILE @@FETCH_STATUS = 0 +BEGIN + -- Set the timezone + EXEC('SELECT set_config(''timezone'', ''' + @timezone + ''', false)'); + + -- Cursor for date parts + DECLARE datepart_cursor CURSOR FOR SELECT DatePartName FROM date_part_vu_prepare_DateParts; + OPEN datepart_cursor; + FETCH NEXT FROM datepart_cursor INTO @datepart; + + WHILE @@FETCH_STATUS = 0 + BEGIN + -- Cursor for data types + DECLARE datatype_cursor CURSOR FOR + SELECT 'DATETIME', 'TestDateTime' UNION ALL + SELECT 'DATETIMEOFFSET', 'TestDateTimeOffset' UNION ALL + SELECT 'DATETIME2', 'TestDateTime2' UNION ALL + SELECT 'SMALLDATETIME', 'TestSmallDateTime'; + OPEN datatype_cursor; + FETCH NEXT FROM datatype_cursor INTO @datatype, @datecol; + + WHILE @@FETCH_STATUS = 0 + BEGIN + -- Cursor for test dates + DECLARE testdate_cursor CURSOR FOR SELECT TestDateTime FROM date_part_vu_prepare_TestDates; + OPEN testdate_cursor; + FETCH NEXT FROM testdate_cursor INTO @testdate; + + WHILE @@FETCH_STATUS = 0 + BEGIN + SET @sql = N' + INSERT INTO date_part_vu_prepare_TestResults (TestCase, TimeZone, DataType, InputDate, DatePart, DatePartValue, DateName) + SELECT + ''Test: '' + CONVERT(VARCHAR, ' + @datecol + ', 120) + '' in ' + @timezone + ''' AS TestCase, + ''' + @timezone + ''' AS TimeZone, + ''' + @datatype + ''' AS DataType, + CONVERT(VARCHAR, ' + @datecol + ', 120) AS InputDate, + ''' + @datepart + ''' AS DatePart, + DATEPART(' + @datepart + ', ' + @datecol + ') AS DatePartValue, + DATENAME(' + @datepart + ', ' + @datecol + ') AS DateName + FROM date_part_vu_prepare_TestDates + WHERE TestDateTime = ''' + CONVERT(VARCHAR, @testdate, 120) + ''''; + + EXEC sp_executesql @sql; + + FETCH NEXT FROM testdate_cursor INTO @testdate; + END + + CLOSE testdate_cursor; + DEALLOCATE testdate_cursor; + + FETCH NEXT FROM datatype_cursor INTO @datatype, @datecol; + END + + CLOSE datatype_cursor; + DEALLOCATE datatype_cursor; + + FETCH NEXT FROM datepart_cursor INTO @datepart; + END + + CLOSE datepart_cursor; + DEALLOCATE datepart_cursor; + + FETCH NEXT FROM timezone_cursor INTO @timezone; +END + +CLOSE timezone_cursor; +DEALLOCATE timezone_cursor; +GO + +-- Analyze results +SELECT * FROM date_part_vu_prepare_TestResults +ORDER BY DataType, InputDate, TimeZone, DatePart; +GO + +-- Check for any discrepancies +SELECT + DataType, + InputDate, + DatePart, + COUNT(DISTINCT DatePartValue) AS UniqueDatePartValues, + COUNT(DISTINCT DateName) AS UniqueDateNames +FROM date_part_vu_prepare_TestResults +GROUP BY DataType, InputDate, DatePart +HAVING + COUNT(DISTINCT DatePartValue) > 1 OR + COUNT(DISTINCT DateName) > 1; +GO + +-- Reset Timezone +SELECT set_config('timezone', 'UTC', false) +GO \ No newline at end of file diff --git a/test/JDBC/input/interoperability/TestBasicInterop.mix b/test/JDBC/input/interoperability/TestBasicInterop.mix index 589497d7cd..592f191182 100644 --- a/test/JDBC/input/interoperability/TestBasicInterop.mix +++ b/test/JDBC/input/interoperability/TestBasicInterop.mix @@ -127,3 +127,17 @@ GO -- psql DROP PROCEDURE pg_interop_proc_sp_exec GO + +-- tsql +CREATE TABLE babel_5446 (Test INT NULL) +GO +INSERT INTO babel_5446 SELECT ISNUMERIC('test') AS my_isnumeric +GO +SELECT @@trancount +GO + +INSERT INTO babel_5446 SELECT ISNUMERIC('test') AS my_isnumeric +SELECT @@trancount +GO +DROP TABLE babel_5446 +GO diff --git a/test/JDBC/input/openjson/BABEL-5054-vu-prepare.sql b/test/JDBC/input/openjson/BABEL-5054-vu-prepare.sql new file mode 100644 index 0000000000..d264d3ac50 --- /dev/null +++ b/test/JDBC/input/openjson/BABEL-5054-vu-prepare.sql @@ -0,0 +1,2663 @@ +CREATE PROCEDURE BABEL_5054_vu_prepare_p1 +AS +BEGIN + DECLARE @jsonInventory NVARCHAR(MAX) = N'{ + "Warehouse": { + "WarehouseID": { + "ScanDate": "2023-01-03", + "FacilityCode": "WHSE01", + "InventoryType": "ProductType", + "ValidFrom": "2023-01-03", + "ValidTo": "2023-02-28", + "Zones": "ZONE_A,ZONE_B,ZONE_C", + "Sections": "SEC1,SEC2,SEC3", + "IsActive": "true", + "RequestMode": "STANDARD", + "MaxResults": "100", + "LocationID": "LOC123", + "TrackingEnabled": "true", + "BatchNumber": "BTH2023001", + "SensorID": "1234", + "ReadingID": "5678" + }, + "SystemMetadata": { + "TotalDays": "30", + "TotalRecords": "15", + "HasMoreRecords": "false", + "IsComplete": "true", + "LastUpdate": "2023-01-03T14:30:00", + "ProcessingTime": "1.5", + "DataQuality": "HIGH" + }, + "FacilityDailyStatusArray": { + "FacilityDailyStatus": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "100", + "MaintenanceSpace": "50", + "AvailableSpace": "800", + "AllocatedSpace": "100", + "TotalUsed": "200", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "8", + "OperationalHours": "24", + "PowerConsumption": "450.75", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-04", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-05", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-06", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-07", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-08", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-09", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-10", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + } + ] + }, + "StorageTypeArray": { + "StorageType": [ + { + "StorageCode": "COLD", + "StorageName": "Cold Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "false", + "Zone": "ZONE_A", + "MaxWeight": "5000", + "StorageClass": "CLASS_A", + "SecurityLevel": "HIGH", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "500", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "400", + "AllocatedSpace": "50", + "TotalUsed": "100", + "TotalCapacity": "500", + "Temperature": "-18.5", + "Humidity": "45", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-02-01", + "AlertCount": "0", + "DoorOpenCount": "24", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + }, + { + "Date": "2023-01-04", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "500", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "380", + "AllocatedSpace": "70", + "TotalUsed": "120", + "TotalCapacity": "500", + "Temperature": "-18.2", + "Humidity": "44", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-02-01", + "AlertCount": "1", + "DoorOpenCount": "28", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + } + ] + } + }, + { + "StorageCode": "FRSH", + "StorageName": "Fresh Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "false", + "Zone": "ZONE_B", + "MaxWeight": "3000", + "StorageClass": "CLASS_B", + "SecurityLevel": "MEDIUM", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "300", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "200", + "AllocatedSpace": "50", + "TotalUsed": "100", + "TotalCapacity": "300", + "Temperature": "4.2", + "Humidity": "65", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-02", + "NextMaintenance": "2023-02-02", + "AlertCount": "0", + "DoorOpenCount": "35", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + } + ] + } + }, + { + "StorageCode": "HAZMT", + "StorageName": "Hazmat Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "true", + "Zone": "ZONE_C", + "MaxWeight": "2000", + "StorageClass": "CLASS_H", + "SecurityLevel": "MAXIMUM", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "200", + "RestrictedAccess": "true", + "MinStaffing": "3", + "AvailableSpace": "150", + "AllocatedSpace": "30", + "TotalUsed": "50", + "TotalCapacity": "200", + "Temperature": "21.0", + "Humidity": "40", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-01-15", + "AlertCount": "0", + "DoorOpenCount": "12", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL", + "HazmatIncidents": "0", + "SafetyInspectionStatus": "PASSED", + "EmergencyResponseReady": "true" + } + ] + } + } + ] + }, + "EnvironmentalMetrics": { + "AirQuality": "GOOD", + "CO2Levels": "450", + "NoiseLevel": "65", + "LightingLevel": "800", + "WaterUsage": "1250", + "WasteManagement": "OPTIMAL", + "RecyclingRate": "85.5" + }, + "SecurityStatus": { + "AccessControlStatus": "ACTIVE", + "SecurityPersonnel": "4", + "CameraStatus": "OPERATIONAL", + "LastIncident": "2022-12-15", + "ThreatLevel": "LOW", + "PerimeterStatus": "SECURE" + } + } + }' + SELECT + WarehouseID.FacilityCode AS FacilityCode, + StorageArr.StorageCode AS Storage_Code, + [Date] AS Metric_Date, + AvailableSpace AS Available_Space, + TotalUsed AS Total_Used, + IsOperational AS Is_Operational, + Temperature AS Storage_Temp, + Humidity AS Storage_Humidity + FROM OPENJSON(@jsonInventory) WITH ( + WarehouseID NVARCHAR(MAX) '$.Warehouse.WarehouseID' AS JSON, + StorageTypeArray NVARCHAR(MAX) '$.Warehouse.StorageTypeArray' AS JSON + ) AS [Warehouse] + OUTER APPLY OPENJSON([Warehouse].WarehouseID) WITH ( + FacilityCode VARCHAR(15) '$.FacilityCode' + ) AS WarehouseID + OUTER APPLY OPENJSON([Warehouse].StorageTypeArray) WITH ( + StorageType NVARCHAR(MAX) '$.StorageType' AS JSON + ) AS Storage + OUTER APPLY OPENJSON(Storage.StorageType) WITH ( + StorageCode VARCHAR(6) '$.StorageCode', + DailyMetricsArray NVARCHAR(MAX) '$.DailyMetricsArray' AS JSON + ) AS StorageArr + OUTER APPLY OPENJSON(StorageArr.DailyMetricsArray) WITH ( + DailyMetrics NVARCHAR(MAX) '$.DailyMetrics' AS JSON + ) AS Metrics + OUTER APPLY OPENJSON(Metrics.DailyMetrics) WITH ( + [Date] DATE '$.Date', + AvailableSpace INT '$.AvailableSpace', + TotalUsed INT '$.TotalUsed', + IsOperational VARCHAR(10) '$.IsOperational', + Temperature DECIMAL(5,2) '$.Temperature', + Humidity INT '$.Humidity' + ) AS DailyMetrics +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p2 +AS +BEGIN + DECLARE @jsonProduction NVARCHAR(MAX) = N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + -- Query to analyze production metrics + SELECT + ProductionID.PlantCode, + MachineArr.MachineCode, + MachineArr.MachineName, + Metrics.DateTime, + Metrics.OperationalStatus, + Metrics.CycleTime, + Metrics.ProductCount, + Metrics.PowerConsumption, + Metrics.OEEScore, + Metrics.MaintenanceScore + FROM OPENJSON(@jsonProduction) WITH ( + ProductionID NVARCHAR(MAX) '$.Factory.ProductionID' AS JSON, + MachineStatusArray NVARCHAR(MAX) '$.Factory.MachineStatusArray' AS JSON + ) AS Factory + OUTER APPLY OPENJSON(Factory.ProductionID) WITH ( + PlantCode VARCHAR(10) '$.PlantCode' + ) AS ProductionID + OUTER APPLY OPENJSON(Factory.MachineStatusArray) WITH ( + MachineStatus NVARCHAR(MAX) '$.MachineStatus' AS JSON + ) AS Machines + OUTER APPLY OPENJSON(Machines.MachineStatus) WITH ( + MachineCode VARCHAR(10) '$.MachineCode', + MachineName VARCHAR(50) '$.MachineName', + HourlyMetricsArray NVARCHAR(MAX) '$.HourlyMetricsArray' AS JSON + ) AS MachineArr + OUTER APPLY OPENJSON(MachineArr.HourlyMetricsArray) WITH ( + HourlyMetrics NVARCHAR(MAX) '$.HourlyMetrics' AS JSON + ) AS HourlyData + OUTER APPLY OPENJSON(HourlyData.HourlyMetrics) WITH ( + DateTime DATETIME '$.DateTime', + OperationalStatus VARCHAR(20) '$.OperationalStatus', + CycleTime DECIMAL(10,2) '$.CycleTime', + ProductCount INT '$.ProductCount', + PowerConsumption DECIMAL(10,2) '$.PowerConsumption', + OEEScore DECIMAL(5,2) '$.OEEScore', + MaintenanceScore DECIMAL(5,2) '$.MaintenanceScore' + ) AS Metrics + WHERE Metrics.DateTime IS NOT NULL + ORDER BY Metrics.DateTime, MachineArr.MachineCode +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p3 +AS +BEGIN + DECLARE @jsonHealthcare NVARCHAR(MAX) = N'{ + "Hospital": { + "MonitoringSession": { + "SessionID": "MON20230103001", + "FacilityCode": "HOSP001", + "UnitCode": "ICU", + "FloorNumber": "3", + "WardCode": "ICU-A", + "StartTime": "2023-01-03T00:00:00", + "EndTime": "2023-01-03T23:59:59", + "StaffShift": "SHIFT_A", + "MonitoringLevel": "INTENSIVE", + "AlertProtocol": "STANDARD", + "DataInterval": "5", + "ResponsiblePhysician": "DR_SMITH", + "NursingTeam": "TEAM_A", + "EmergencyStatus": "NORMAL" + }, + "SystemConfiguration": { + "MonitoringDuration": "24", + "SamplingFrequency": "12", + "DataRetention": "90", + "BackupFrequency": "15", + "AlertThreshold": "CUSTOM", + "EncryptionLevel": "AES256", + "ComplianceMode": "HIPAA", + "DataValidation": "ENABLED" + }, + "PatientMonitoringArray": { + "PatientMonitoring": [ + { + "PatientID": "PT100123", + "AdmissionID": "ADM20230102003", + "Age": "65", + "Gender": "M", + "RiskLevel": "HIGH", + "IsolationStatus": "NONE", + "DiagnosisCode": "ICD10-I21.0", + "VitalSignsArray": { + "VitalSigns": [ + { + "DateTime": "2023-01-03T06:00:00", + "HeartRate": "82", + "BloodPressureSystolic": "135", + "BloodPressureDiastolic": "85", + "Temperature": "37.2", + "RespiratoryRate": "16", + "OxygenSaturation": "97", + "ConsciousnessLevel": "ALERT", + "PainScore": "2", + "GlucoseLevel": "110", + "EtCO2": "35", + "MAP": "95", + "CVP": "8", + "UrinePH": "6.5", + "UrineOutput": "50", + "FluidBalance": "-120", + "NEWS2Score": "2", + "AlertStatus": "NORMAL", + "InterventionRequired": "false" + }, + { + "DateTime": "2023-01-03T07:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T08:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T09:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T10:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T11:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + }, + { + "DateTime": "2023-01-03T12:00:00", + "HeartRate": "85", + "BloodPressureSystolic": "138", + "BloodPressureDiastolic": "88", + "Temperature": "37.3", + "RespiratoryRate": "18", + "OxygenSaturation": "96", + "ConsciousnessLevel": "ALERT", + "PainScore": "3", + "GlucoseLevel": "115", + "EtCO2": "36", + "MAP": "97", + "CVP": "9", + "UrinePH": "6.4", + "UrineOutput": "45", + "FluidBalance": "-150", + "NEWS2Score": "3", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + } + ] + } + }, + { + "PatientID": "PT100124", + "AdmissionID": "ADM20230102004", + "Age": "45", + "Gender": "F", + "RiskLevel": "MEDIUM", + "IsolationStatus": "CONTACT", + "DiagnosisCode": "ICD10-J18.9", + "VitalSignsArray": { + "VitalSigns": [ + { + "DateTime": "2023-01-03T06:00:00", + "HeartRate": "75", + "BloodPressureSystolic": "122", + "BloodPressureDiastolic": "78", + "Temperature": "38.5", + "RespiratoryRate": "20", + "OxygenSaturation": "94", + "ConsciousnessLevel": "ALERT", + "PainScore": "4", + "GlucoseLevel": "105", + "EtCO2": "38", + "MAP": "92", + "CVP": "7", + "UrinePH": "6.2", + "UrineOutput": "40", + "FluidBalance": "-200", + "NEWS2Score": "4", + "AlertStatus": "ELEVATED", + "InterventionRequired": "true" + } + ] + } + } + ] + }, + "MedicalDeviceArray": { + "MedicalDevice": [ + { + "DeviceID": "VEN001", + "DeviceType": "VENTILATOR", + "Manufacturer": "MEDTECH", + "Model": "VENT-2000", + "LastCalibration": "2022-12-15", + "NextCalibration": "2023-03-15", + "AssignedPatient": "PT100123", + "MetricsArray": { + "Metrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "Mode": "SIMV", + "TidalVolume": "450", + "RespiratoryRate": "16", + "PEEP": "5", + "FiO2": "40", + "PIP": "25", + "InspiratoryPressure": "15", + "ExpiratoryPressure": "5", + "MinuteVolume": "7.2", + "AlarmStatus": "NORMAL", + "BatteryLevel": "85", + "MaintenanceStatus": "OK", + "ComplianceScore": "98.5", + "ErrorCount": "0" + } + ] + } + }, + { + "DeviceID": "INF001", + "DeviceType": "INFUSION_PUMP", + "Manufacturer": "MEDTECH", + "Model": "INFUS-3000", + "LastCalibration": "2022-12-20", + "NextCalibration": "2023-03-20", + "AssignedPatient": "PT100124", + "MetricsArray": { + "Metrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "FlowRate": "125", + "TotalVolume": "500", + "InfusedVolume": "125", + "RemainingVolume": "375", + "DrugConcentration": "50", + "DoseRate": "6.25", + "OcclusionPressure": "150", + "BatteryLevel": "90", + "AlarmStatus": "NORMAL", + "MaintenanceStatus": "OK", + "ErrorCount": "0" + } + ] + } + } + ] + }, + "EnvironmentalMetrics": { + "RoomTemperature": "21.5", + "Humidity": "45", + "AirPressure": "101.3", + "AirExchangeRate": "12", + "CO2Level": "450", + "LightLevel": "250", + "NoiseLevel": "45", + "IsolationPressure": "-2.5" + }, + "QualityMetrics": { + "InfectionRate": "0.1", + "HandHygieneCompliance": "95.5", + "PatientFallRate": "0.0", + "MedicationErrors": "0", + "BedOccupancyRate": "85.5", + "AverageResponseTime": "2.5", + "PatientSatisfaction": "92.0" + } + } + }' + + -- Query to analyze patient vital signs and device metrics + SELECT + m.SessionID, + p.PatientID, + p.DiagnosisCode, + v.DateTime, + v.HeartRate, + v.BloodPressureSystolic, + v.BloodPressureDiastolic, + v.Temperature, + v.OxygenSaturation, + v.NEWS2Score, + v.AlertStatus, + d.DeviceID, + d.DeviceType, + dm.OperationalStatus, + dm.AlarmStatus + FROM OPENJSON(@jsonHealthcare) WITH ( + MonitoringSession NVARCHAR(MAX) '$.Hospital.MonitoringSession' AS JSON, + PatientMonitoringArray NVARCHAR(MAX) '$.Hospital.PatientMonitoringArray' AS JSON, + MedicalDeviceArray NVARCHAR(MAX) '$.Hospital.MedicalDeviceArray' AS JSON + ) AS Hospital + OUTER APPLY OPENJSON(Hospital.MonitoringSession) WITH ( + SessionID VARCHAR(20) '$.SessionID' + ) AS m + OUTER APPLY OPENJSON(Hospital.PatientMonitoringArray) WITH ( + PatientMonitoring NVARCHAR(MAX) '$.PatientMonitoring' AS JSON + ) AS Patients + OUTER APPLY OPENJSON(Patients.PatientMonitoring) WITH ( + PatientID VARCHAR(10) '$.PatientID', + DiagnosisCode VARCHAR(20) '$.DiagnosisCode', + VitalSignsArray NVARCHAR(MAX) '$.VitalSignsArray' AS JSON + ) AS p + OUTER APPLY OPENJSON(p.VitalSignsArray) WITH ( + VitalSigns NVARCHAR(MAX) '$.VitalSigns' AS JSON + ) AS Vitals + OUTER APPLY OPENJSON(Vitals.VitalSigns) WITH ( + DateTime DATETIME '$.DateTime', + HeartRate INT '$.HeartRate', + BloodPressureSystolic INT '$.BloodPressureSystolic', + BloodPressureDiastolic INT '$.BloodPressureDiastolic', + Temperature DECIMAL(4,1) '$.Temperature', + OxygenSaturation INT '$.OxygenSaturation', + NEWS2Score INT '$.NEWS2Score', + AlertStatus VARCHAR(20) '$.AlertStatus' + ) AS v + OUTER APPLY OPENJSON(Hospital.MedicalDeviceArray) WITH ( + MedicalDevice NVARCHAR(MAX) '$.MedicalDevice' AS JSON + ) AS Devices + OUTER APPLY OPENJSON(Devices.MedicalDevice) WITH ( + DeviceID VARCHAR(10) '$.DeviceID', + DeviceType VARCHAR(20) '$.DeviceType', + AssignedPatient VARCHAR(10) '$.AssignedPatient', + MetricsArray NVARCHAR(MAX) '$.MetricsArray' AS JSON + ) AS d + OUTER APPLY OPENJSON(d.MetricsArray) WITH ( + Metrics NVARCHAR(MAX) '$.Metrics' AS JSON + ) AS DeviceMetrics + OUTER APPLY OPENJSON(DeviceMetrics.Metrics) WITH ( + DateTime DATETIME '$.DateTime', + OperationalStatus VARCHAR(20) '$.OperationalStatus', + AlarmStatus VARCHAR(20) '$.AlarmStatus' + ) AS dm + WHERE p.PatientID = d.AssignedPatient + AND v.DateTime = dm.DateTime + ORDER BY v.DateTime, p.PatientID +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p4 +AS +BEGIN + DECLARE @json NVARCHAR(MAX); + SET @json=N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + + SELECT * FROM OPENJSON(@json, '$') with (name nvarchar(max) '$' AS JSON) +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p5 +AS +BEGIN + DECLARE @json NVARCHAR(MAX); + SET @json=N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + + SELECT * FROM OPENJSON(@json, '$') with (name sys.nvarchar(max) '$' AS JSON) +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p6 +AS +BEGIN + DECLARE @json NVARCHAR(MAX); + SET @json=N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + + SELECT * FROM OPENJSON(@json, '$') with (name nvarchar(max) '$.Factory' AS JSON) +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p7 + @jsonInventory NVARCHAR(MAX) +AS +BEGIN + SELECT + WarehouseID.FacilityCode AS FacilityCode, + StorageArr.StorageCode AS Storage_Code, + [Date] AS Metric_Date, + AvailableSpace AS Available_Space, + TotalUsed AS Total_Used, + IsOperational AS Is_Operational, + Temperature AS Storage_Temp, + Humidity AS Storage_Humidity + FROM OPENJSON(@jsonInventory) WITH ( + WarehouseID NVARCHAR(MAX) '$.Warehouse.WarehouseID' AS JSON, + StorageTypeArray NVARCHAR(MAX) '$.Warehouse.StorageTypeArray' AS JSON + ) AS [Warehouse] + OUTER APPLY OPENJSON([Warehouse].WarehouseID) WITH ( + FacilityCode VARCHAR(15) '$.FacilityCode' + ) AS WarehouseID + OUTER APPLY OPENJSON([Warehouse].StorageTypeArray) WITH ( + StorageType NVARCHAR(MAX) '$.StorageType' AS JSON + ) AS Storage + OUTER APPLY OPENJSON(Storage.StorageType) WITH ( + StorageCode VARCHAR(6) '$.StorageCode', + DailyMetricsArray NVARCHAR(MAX) '$.DailyMetricsArray' AS JSON + ) AS StorageArr + OUTER APPLY OPENJSON(StorageArr.DailyMetricsArray) WITH ( + DailyMetrics NVARCHAR(MAX) '$.DailyMetrics' AS JSON + ) AS Metrics + OUTER APPLY OPENJSON(Metrics.DailyMetrics) WITH ( + [Date] DATE '$.Date', + AvailableSpace INT '$.AvailableSpace', + TotalUsed INT '$.TotalUsed', + IsOperational VARCHAR(10) '$.IsOperational', + Temperature DECIMAL(5,2) '$.Temperature', + Humidity INT '$.Humidity' + ) AS DailyMetrics +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p8 + @jsonProduction NVARCHAR(MAX) +AS +BEGIN + SELECT + ProductionID.PlantCode, + MachineArr.MachineCode, + MachineArr.MachineName, + Metrics.DateTime, + Metrics.OperationalStatus, + Metrics.CycleTime, + Metrics.ProductCount, + Metrics.PowerConsumption, + Metrics.OEEScore, + Metrics.MaintenanceScore + FROM OPENJSON(@jsonProduction) WITH ( + ProductionID NVARCHAR(MAX) '$.Factory.ProductionID' AS JSON, + MachineStatusArray NVARCHAR(MAX) '$.Factory.MachineStatusArray' AS JSON + ) AS Factory + OUTER APPLY OPENJSON(Factory.ProductionID) WITH ( + PlantCode VARCHAR(10) '$.PlantCode' + ) AS ProductionID + OUTER APPLY OPENJSON(Factory.MachineStatusArray) WITH ( + MachineStatus NVARCHAR(MAX) '$.MachineStatus' AS JSON + ) AS Machines + OUTER APPLY OPENJSON(Machines.MachineStatus) WITH ( + MachineCode VARCHAR(10) '$.MachineCode', + MachineName VARCHAR(50) '$.MachineName', + HourlyMetricsArray NVARCHAR(MAX) '$.HourlyMetricsArray' AS JSON + ) AS MachineArr + OUTER APPLY OPENJSON(MachineArr.HourlyMetricsArray) WITH ( + HourlyMetrics NVARCHAR(MAX) '$.HourlyMetrics' AS JSON + ) AS HourlyData + OUTER APPLY OPENJSON(HourlyData.HourlyMetrics) WITH ( + DateTime DATETIME '$.DateTime', + OperationalStatus VARCHAR(20) '$.OperationalStatus', + CycleTime DECIMAL(10,2) '$.CycleTime', + ProductCount INT '$.ProductCount', + PowerConsumption DECIMAL(10,2) '$.PowerConsumption', + OEEScore DECIMAL(5,2) '$.OEEScore', + MaintenanceScore DECIMAL(5,2) '$.MaintenanceScore' + ) AS Metrics + WHERE Metrics.DateTime IS NOT NULL + ORDER BY Metrics.DateTime, MachineArr.MachineCode +END; +GO + + +CREATE PROCEDURE BABEL_5054_vu_prepare_p9 + @json NVARCHAR(MAX) +AS +BEGIN + SELECT * FROM OPENJSON(@json, '$') with (name nvarchar(max) '$.Factory' AS JSON) +END; +GO + + +CREATE VIEW BABEL_5054_vu_prepare_v1 +AS + SELECT * FROM OPENJSON(N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' + , '$') with (name nvarchar(max) '$.Factory' AS JSON); +GO + + +CREATE VIEW BABEL_5054_vu_prepare_v2 +AS + SELECT + ProductionID.PlantCode, + MachineArr.MachineCode, + MachineArr.MachineName, + Metrics.DateTime, + Metrics.OperationalStatus, + Metrics.CycleTime, + Metrics.ProductCount, + Metrics.PowerConsumption, + Metrics.OEEScore, + Metrics.MaintenanceScore + FROM OPENJSON(N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }') WITH ( + ProductionID NVARCHAR(MAX) '$.Factory.ProductionID' AS JSON, + MachineStatusArray NVARCHAR(MAX) '$.Factory.MachineStatusArray' AS JSON + ) AS Factory + OUTER APPLY OPENJSON(Factory.ProductionID) WITH ( + PlantCode VARCHAR(10) '$.PlantCode' + ) AS ProductionID + OUTER APPLY OPENJSON(Factory.MachineStatusArray) WITH ( + MachineStatus NVARCHAR(MAX) '$.MachineStatus' AS JSON + ) AS Machines + OUTER APPLY OPENJSON(Machines.MachineStatus) WITH ( + MachineCode VARCHAR(10) '$.MachineCode', + MachineName VARCHAR(50) '$.MachineName', + HourlyMetricsArray NVARCHAR(MAX) '$.HourlyMetricsArray' AS JSON + ) AS MachineArr + OUTER APPLY OPENJSON(MachineArr.HourlyMetricsArray) WITH ( + HourlyMetrics NVARCHAR(MAX) '$.HourlyMetrics' AS JSON + ) AS HourlyData + OUTER APPLY OPENJSON(HourlyData.HourlyMetrics) WITH ( + DateTime DATETIME '$.DateTime', + OperationalStatus VARCHAR(20) '$.OperationalStatus', + CycleTime DECIMAL(10,2) '$.CycleTime', + ProductCount INT '$.ProductCount', + PowerConsumption DECIMAL(10,2) '$.PowerConsumption', + OEEScore DECIMAL(5,2) '$.OEEScore', + MaintenanceScore DECIMAL(5,2) '$.MaintenanceScore' + ) AS Metrics + WHERE Metrics.DateTime IS NOT NULL + ORDER BY Metrics.DateTime, MachineArr.MachineCode +GO \ No newline at end of file diff --git a/test/JDBC/input/openjson/BABEL-5054-vu-verify.sql b/test/JDBC/input/openjson/BABEL-5054-vu-verify.sql new file mode 100644 index 0000000000..2b2a41d22d --- /dev/null +++ b/test/JDBC/input/openjson/BABEL-5054-vu-verify.sql @@ -0,0 +1,1007 @@ +-- Intermediate JSON result exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p1 +GO +DROP PROCEDURE BABEL_5054_vu_prepare_p1 +GO + +-- Intermediate JSON result exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p2 +GO +DROP PROCEDURE BABEL_5054_vu_prepare_p2 +GO + +-- Intermediate JSON result exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p3 +GO +DROP PROCEDURE BABEL_5054_vu_prepare_p3 +GO + +-- JSON in a single result cell exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p4 +GO +DROP PROCEDURE BABEL_5054_vu_prepare_p4 +GO + +-- JSON in a single result cell exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p5 +GO +DROP PROCEDURE BABEL_5054_vu_prepare_p5 +GO + +-- JSON in a single result cell exceeds 4000 characters in length +-- Expect no error +EXEC BABEL_5054_vu_prepare_p6 +GO +DROP PROCEDURE BABEL_5054_vu_prepare_p6 +GO + +-- long JSON exceeding 4000 characters as input +-- Expect no error +DECLARE @json NVARCHAR(MAX) = N'{ + "Warehouse": { + "WarehouseID": { + "ScanDate": "2023-01-03", + "FacilityCode": "WHSE01", + "InventoryType": "ProductType", + "ValidFrom": "2023-01-03", + "ValidTo": "2023-02-28", + "Zones": "ZONE_A,ZONE_B,ZONE_C", + "Sections": "SEC1,SEC2,SEC3", + "IsActive": "true", + "RequestMode": "STANDARD", + "MaxResults": "100", + "LocationID": "LOC123", + "TrackingEnabled": "true", + "BatchNumber": "BTH2023001", + "SensorID": "1234", + "ReadingID": "5678" + }, + "SystemMetadata": { + "TotalDays": "30", + "TotalRecords": "15", + "HasMoreRecords": "false", + "IsComplete": "true", + "LastUpdate": "2023-01-03T14:30:00", + "ProcessingTime": "1.5", + "DataQuality": "HIGH" + }, + "FacilityDailyStatusArray": { + "FacilityDailyStatus": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "100", + "MaintenanceSpace": "50", + "AvailableSpace": "800", + "AllocatedSpace": "100", + "TotalUsed": "200", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "8", + "OperationalHours": "24", + "PowerConsumption": "450.75", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-04", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-05", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-06", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-07", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-08", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-09", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + }, + { + "Date": "2023-01-10", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "1000", + "RestrictedAccess": "false", + "MinStaffing": "5", + "MinStorageTime": "24", + "MaxStorageTime": "720", + "ReservedSpace": "150", + "MaintenanceSpace": "50", + "AvailableSpace": "750", + "AllocatedSpace": "150", + "TotalUsed": "250", + "TotalCapacity": "1000", + "BlockedSpace": "50", + "PhysicalCapacity": "1000", + "Adjustment": "0", + "StaffingLevel": "10", + "OperationalHours": "24", + "PowerConsumption": "475.25", + "AlertLevel": "GREEN", + "MaintenanceScheduled": "false" + } + ] + }, + "StorageTypeArray": { + "StorageType": [ + { + "StorageCode": "COLD", + "StorageName": "Cold Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "false", + "Zone": "ZONE_A", + "MaxWeight": "5000", + "StorageClass": "CLASS_A", + "SecurityLevel": "HIGH", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "500", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "400", + "AllocatedSpace": "50", + "TotalUsed": "100", + "TotalCapacity": "500", + "Temperature": "-18.5", + "Humidity": "45", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-02-01", + "AlertCount": "0", + "DoorOpenCount": "24", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + }, + { + "Date": "2023-01-04", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "500", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "380", + "AllocatedSpace": "70", + "TotalUsed": "120", + "TotalCapacity": "500", + "Temperature": "-18.2", + "Humidity": "44", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-02-01", + "AlertCount": "1", + "DoorOpenCount": "28", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + } + ] + } + }, + { + "StorageCode": "FRSH", + "StorageName": "Fresh Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "false", + "Zone": "ZONE_B", + "MaxWeight": "3000", + "StorageClass": "CLASS_B", + "SecurityLevel": "MEDIUM", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "300", + "RestrictedAccess": "false", + "MinStaffing": "2", + "AvailableSpace": "200", + "AllocatedSpace": "50", + "TotalUsed": "100", + "TotalCapacity": "300", + "Temperature": "4.2", + "Humidity": "65", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-02", + "NextMaintenance": "2023-02-02", + "AlertCount": "0", + "DoorOpenCount": "35", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL" + } + ] + } + }, + { + "StorageCode": "HAZMT", + "StorageName": "Hazmat Storage", + "IsTemperatureControlled": "true", + "IsHazmat": "true", + "Zone": "ZONE_C", + "MaxWeight": "2000", + "StorageClass": "CLASS_H", + "SecurityLevel": "MAXIMUM", + "RequiresSpecialHandling": "true", + "DailyMetricsArray": { + "DailyMetrics": [ + { + "Date": "2023-01-03", + "IsOperational": "true", + "MaintenanceMode": "false", + "MinCapacity": "0", + "MaxCapacity": "200", + "RestrictedAccess": "true", + "MinStaffing": "3", + "AvailableSpace": "150", + "AllocatedSpace": "30", + "TotalUsed": "50", + "TotalCapacity": "200", + "Temperature": "21.0", + "Humidity": "40", + "PowerStatus": "NORMAL", + "BackupPower": "READY", + "LastMaintenance": "2023-01-01", + "NextMaintenance": "2023-01-15", + "AlertCount": "0", + "DoorOpenCount": "12", + "TemperatureBreaches": "0", + "ProductRotationStatus": "NORMAL", + "HazmatIncidents": "0", + "SafetyInspectionStatus": "PASSED", + "EmergencyResponseReady": "true" + } + ] + } + } + ] + }, + "EnvironmentalMetrics": { + "AirQuality": "GOOD", + "CO2Levels": "450", + "NoiseLevel": "65", + "LightingLevel": "800", + "WaterUsage": "1250", + "WasteManagement": "OPTIMAL", + "RecyclingRate": "85.5" + }, + "SecurityStatus": { + "AccessControlStatus": "ACTIVE", + "SecurityPersonnel": "4", + "CameraStatus": "OPERATIONAL", + "LastIncident": "2022-12-15", + "ThreatLevel": "LOW", + "PerimeterStatus": "SECURE" + } + } + }' +EXEC BABEL_5054_vu_prepare_p7 @jsonInventory = @json +GO +DROP PROCEDURE BABEL_5054_vu_prepare_p7 +GO + + +-- long JSON exceeding 4000 characters as input +-- Expect no error +DECLARE @json NVARCHAR(MAX) = N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' +EXEC BABEL_5054_vu_prepare_p8 @jsonProduction = @json +GO +DROP PROCEDURE BABEL_5054_vu_prepare_p8 +GO + + +-- long JSON exceeding 4000 characters as input +-- Expect no error +DECLARE @json NVARCHAR(MAX) = N'{ + "Factory": { + "ProductionID": { + "TimeStamp": "2023-01-03T00:00:00", + "PlantCode": "MFGP01", + "ShiftCode": "SHIFT_A", + "ProductionLine": "LINE_001", + "BatchStart": "2023-01-03T06:00:00", + "BatchEnd": "2023-01-03T14:00:00", + "ProductCategories": "AUTOMOTIVE,ELECTRONICS", + "QualityLevel": "PREMIUM", + "IsActive": "true", + "MonitoringMode": "REAL_TIME", + "SamplingRate": "60", + "SupervisorID": "SUP_123", + "CertificationLevel": "ISO9001", + "ControlSystemVersion": "5.2.1" + }, + "SystemStatus": { + "MonitoringPeriod": "28", + "DataPoints": "1440", + "DataIntegrity": "99.98", + "LastBackup": "2023-01-02T23:00:00", + "SystemHealth": "OPTIMAL", + "AlertStatus": "NORMAL", + "MaintenanceWindow": "SCHEDULED", + "CalibrationStatus": "VALID" + }, + "ProductionLineStatusArray": { + "ProductionLineStatus": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "95.5", + "TargetSpeed": "100.0", + "DefectRate": "0.12", + "ProductionRate": "857", + "DowntimeMinutes": "0", + "WorkerCount": "12", + "EnergyConsumption": "450.75", + "MaterialEfficiency": "98.5", + "QualityScore": "99.2", + "TemperatureZone1": "22.5", + "TemperatureZone2": "23.1", + "HumidityZone1": "45", + "HumidityZone2": "47", + "VibrationLevel": "0.15", + "NoiseLevel": "72.5", + "PressureReading": "101.3", + "SafetyIncidents": "0", + "MaintenanceAlerts": "0" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CurrentSpeed": "97.2", + "TargetSpeed": "100.0", + "DefectRate": "0.15", + "ProductionRate": "862", + "DowntimeMinutes": "5", + "WorkerCount": "12", + "EnergyConsumption": "455.25", + "MaterialEfficiency": "98.2", + "QualityScore": "99.1", + "TemperatureZone1": "22.7", + "TemperatureZone2": "23.3", + "HumidityZone1": "46", + "HumidityZone2": "48", + "VibrationLevel": "0.17", + "NoiseLevel": "73.1", + "PressureReading": "101.2", + "SafetyIncidents": "0", + "MaintenanceAlerts": "1" + } + ] + }, + "MachineStatusArray": { + "MachineStatus": [ + { + "MachineCode": "ROB01", + "MachineName": "Robotic Arm Assembly", + "MachineType": "ROBOTICS", + "Zone": "ZONE_A", + "InstallDate": "2022-01-15", + "LastMaintenance": "2022-12-15", + "CertificationExpiry": "2024-01-15", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.5", + "TargetCycleTime": "45.0", + "ErrorCount": "0", + "ProductCount": "79", + "RejectCount": "1", + "PowerConsumption": "2.75", + "MotorTemperature": "42.5", + "OilPressure": "95.5", + "VibrationReading": "0.12", + "AccuracyScore": "99.8", + "WearLevel": "15.5", + "MaintenanceScore": "98.5", + "PerformanceIndex": "97.2", + "QualityIndex": "99.5", + "AvailabilityIndex": "99.8", + "OEEScore": "96.5" + }, + { + "DateTime": "2023-01-03T07:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T08:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T09:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T10:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + }, + { + "DateTime": "2023-01-03T11:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "45.8", + "TargetCycleTime": "45.0", + "ErrorCount": "1", + "ProductCount": "77", + "RejectCount": "2", + "PowerConsumption": "2.82", + "MotorTemperature": "43.1", + "OilPressure": "95.2", + "VibrationReading": "0.14", + "AccuracyScore": "99.7", + "WearLevel": "15.7", + "MaintenanceScore": "98.2", + "PerformanceIndex": "96.8", + "QualityIndex": "99.3", + "AvailabilityIndex": "99.7", + "OEEScore": "95.8" + } + ] + } + }, + { + "MachineCode": "CNC01", + "MachineName": "CNC Milling Station", + "MachineType": "CNC", + "Zone": "ZONE_B", + "InstallDate": "2021-06-20", + "LastMaintenance": "2022-12-20", + "CertificationExpiry": "2024-06-20", + "HourlyMetricsArray": { + "HourlyMetrics": [ + { + "DateTime": "2023-01-03T06:00:00", + "OperationalStatus": "RUNNING", + "CycleTime": "32.5", + "TargetCycleTime": "32.0", + "ErrorCount": "0", + "ProductCount": "110", + "RejectCount": "2", + "PowerConsumption": "4.25", + "SpindleTemperature": "55.5", + "CoolantLevel": "92.5", + "ToolWear": "25.5", + "AccuracyScore": "99.5", + "SurfaceFinish": "0.8", + "MaintenanceScore": "97.5", + "PerformanceIndex": "96.8", + "QualityIndex": "98.9", + "AvailabilityIndex": "99.5", + "OEEScore": "95.2" + } + ] + } + } + ] + }, + "QualityMetrics": { + "BatchDefectRate": "0.14", + "FirstPassYield": "98.5", + "ReworkRate": "1.2", + "ScrapRate": "0.3", + "CustomerComplaints": "0", + "QualityAuditScore": "95.5", + "ProcessCapabilityIndex": "1.45" + }, + "ResourceConsumption": { + "ElectricityUsage": "2750.5", + "WaterUsage": "850.2", + "CompressedAir": "1200.5", + "RawMaterialUsage": "2500.0", + "WasteGenerated": "45.5", + "RecycledMaterial": "40.2", + "CarbonFootprint": "1250.75" + } + } + }' +EXEC BABEL_5054_vu_prepare_p9 @json = @json +GO +DROP PROCEDURE BABEL_5054_vu_prepare_p9 +GO + + +-- long JSON exceeding 4000 characters in create view +-- Expect no error +SELECT * FROM BABEL_5054_vu_prepare_v1 +GO +DROP VIEW BABEL_5054_vu_prepare_v1 +GO + + +-- long JSON exceeding 4000 characters in create view +-- Expect no error +SELECT * FROM BABEL_5054_vu_prepare_v2 +GO +DROP VIEW BABEL_5054_vu_prepare_v2 +GO \ No newline at end of file diff --git a/test/JDBC/input/ownership_restrictions_from_pg_su_user.mix b/test/JDBC/input/ownership_restrictions_from_pg_su_user.mix index 0a95e4d400..035ca64154 100644 --- a/test/JDBC/input/ownership_restrictions_from_pg_su_user.mix +++ b/test/JDBC/input/ownership_restrictions_from_pg_su_user.mix @@ -1,7 +1,7 @@ -- tsql -- This test file checks the changes which are ignored in the tod run -- As tod will not be able to create an SUPERUSER --- and testing on jdbc_testdb(where bbf is initialized) is not possible +-- and testing on babelfish_db(where bbf is initialized) is not possible CREATE LOGIN ownership_restrictions_from_pg_login1 WITH password = '12345678'; GO @@ -22,44 +22,44 @@ GO -- If tsql login connected through psql Alter ROLE of an bbf created logins/user/roles for password, -- connection limit and valid until should be working fine -- and the rest of alter role operations should throw an error. -ALTER ROLE ALL IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE ALL IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE master_ownership_restrictions_from_pg_role1 IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE master_ownership_restrictions_from_pg_role1 IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE CURRENT_ROLE IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE CURRENT_ROLE IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE CURRENT_USER IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE CURRENT_USER IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE SESSION_USER IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE SESSION_USER IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE ownership_restrictions_from_pg_login1 IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE ownership_restrictions_from_pg_login1 IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -- psql user=ownership_restrictions_from_pg_test_user password=12345678 -- For plain psql user Alter ROLE of an bbf created logins/user/roles for password, -- connection limit and valid until should be working fine -- and the rest of alter role operations should throw an error. -ALTER ROLE ALL IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE ALL IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE master_ownership_restrictions_from_pg_role1 IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE master_ownership_restrictions_from_pg_role1 IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE CURRENT_ROLE IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE CURRENT_ROLE IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE CURRENT_USER IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE CURRENT_USER IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE SESSION_USER IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE SESSION_USER IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -ALTER ROLE ownership_restrictions_from_pg_login1 IN DATABASE jdbc_testdb set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; +ALTER ROLE ownership_restrictions_from_pg_login1 IN DATABASE babelfish_db set babelfishpg_tsql.ownership_restrictions_from_pg_test_variable = 101; GO -- psql user=ownership_restrictions_from_pg_test_su_user password=12345678 diff --git a/test/JDBC/input/pg_regress/load_aggtest.sh b/test/JDBC/input/pg_regress/load_aggtest.sh index aabfb30439..adf961b490 100644 --- a/test/JDBC/input/pg_regress/load_aggtest.sh +++ b/test/JDBC/input/pg_regress/load_aggtest.sh @@ -1,5 +1,5 @@ echo "-----copy aggtest table from /data/agg.data-----" -PGPASSWORD=12345678 psql -U jdbc_user -d jdbc_testdb -a << EOF +PGPASSWORD=12345678 psql -U jdbc_user -d babelfish_db -a << EOF \getenv pg_src PG_SRC \set filename :pg_src '/src/test/regress/data/agg.data' COPY master_dbo.aggtest FROM :'filename'; diff --git a/test/JDBC/input/pg_regress/load_emp.sh b/test/JDBC/input/pg_regress/load_emp.sh index 92ea9db97a..eb482d45ec 100644 --- a/test/JDBC/input/pg_regress/load_emp.sh +++ b/test/JDBC/input/pg_regress/load_emp.sh @@ -1,5 +1,5 @@ echo "-----copy emp table from /data/emp.data-----" -PGPASSWORD=12345678 psql -U jdbc_user -d jdbc_testdb -a << EOF +PGPASSWORD=12345678 psql -U jdbc_user -d babelfish_db -a << EOF \getenv pg_src PG_SRC \set filename :pg_src '/src/test/regress/data/emp.data' COPY master_dbo.emp FROM :'filename'; diff --git a/test/JDBC/input/pg_regress/load_onek.sh b/test/JDBC/input/pg_regress/load_onek.sh index 9d0c8ef2cf..de24e41f33 100755 --- a/test/JDBC/input/pg_regress/load_onek.sh +++ b/test/JDBC/input/pg_regress/load_onek.sh @@ -1,5 +1,5 @@ echo "-----copy onek table from /data/onek.data-----" -PGPASSWORD=12345678 psql -U jdbc_user -d jdbc_testdb -a << EOF +PGPASSWORD=12345678 psql -U jdbc_user -d babelfish_db -a << EOF \getenv pg_src PG_SRC \set filename :pg_src '/src/test/regress/data/onek.data' COPY master_dbo.onek FROM :'filename'; diff --git a/test/JDBC/input/pg_regress/load_person.sh b/test/JDBC/input/pg_regress/load_person.sh index 3f6ae4499a..bc19497219 100644 --- a/test/JDBC/input/pg_regress/load_person.sh +++ b/test/JDBC/input/pg_regress/load_person.sh @@ -1,5 +1,5 @@ echo "-----copy person table from /data/person.data-----" -PGPASSWORD=12345678 psql -U jdbc_user -d jdbc_testdb -a << EOF +PGPASSWORD=12345678 psql -U jdbc_user -d babelfish_db -a << EOF \getenv pg_src PG_SRC \set filename :pg_src '/src/test/regress/data/person.data' COPY master_dbo.person FROM :'filename'; diff --git a/test/JDBC/input/pg_regress/load_road.sh b/test/JDBC/input/pg_regress/load_road.sh index 7512347f09..19b99c58df 100644 --- a/test/JDBC/input/pg_regress/load_road.sh +++ b/test/JDBC/input/pg_regress/load_road.sh @@ -1,5 +1,5 @@ echo "-----copy road table from /data/streets.data-----" -PGPASSWORD=12345678 psql -U jdbc_user -d jdbc_testdb -a << EOF +PGPASSWORD=12345678 psql -U jdbc_user -d babelfish_db -a << EOF \getenv pg_src PG_SRC \set filename :pg_src '/src/test/regress/data/streets.data' COPY master_dbo.road FROM :'filename'; diff --git a/test/JDBC/input/pg_regress/load_stud_emp.sh b/test/JDBC/input/pg_regress/load_stud_emp.sh index 1d80e45198..a0591eda91 100644 --- a/test/JDBC/input/pg_regress/load_stud_emp.sh +++ b/test/JDBC/input/pg_regress/load_stud_emp.sh @@ -1,5 +1,5 @@ echo "-----copy stud_emp table from /data/stud_emp.data-----" -PGPASSWORD=12345678 psql -U jdbc_user -d jdbc_testdb -a << EOF +PGPASSWORD=12345678 psql -U jdbc_user -d babelfish_db -a << EOF \getenv pg_src PG_SRC \set filename :pg_src '/src/test/regress/data/stud_emp.data' COPY master_dbo.stud_emp FROM :'filename'; diff --git a/test/JDBC/input/pg_regress/load_student.sh b/test/JDBC/input/pg_regress/load_student.sh index 023169e63e..9094f56867 100644 --- a/test/JDBC/input/pg_regress/load_student.sh +++ b/test/JDBC/input/pg_regress/load_student.sh @@ -1,5 +1,5 @@ echo "-----copy student table from /data/student.data-----" -PGPASSWORD=12345678 psql -U jdbc_user -d jdbc_testdb -a << EOF +PGPASSWORD=12345678 psql -U jdbc_user -d babelfish_db -a << EOF \getenv pg_src PG_SRC \set filename :pg_src '/src/test/regress/data/student.data' COPY master_dbo.student FROM :'filename'; diff --git a/test/JDBC/input/pg_regress/load_tenk.sh b/test/JDBC/input/pg_regress/load_tenk.sh index 96c96a647a..89024e05ea 100644 --- a/test/JDBC/input/pg_regress/load_tenk.sh +++ b/test/JDBC/input/pg_regress/load_tenk.sh @@ -1,5 +1,5 @@ echo "-----copy tenk1 table from /data/tenk.data-----" -PGPASSWORD=12345678 psql -U jdbc_user -d jdbc_testdb -a << EOF +PGPASSWORD=12345678 psql -U jdbc_user -d babelfish_db -a << EOF \getenv pg_src PG_SRC \set filename :pg_src '/src/test/regress/data/tenk.data' COPY master_dbo.tenk1 FROM :'filename'; diff --git a/test/JDBC/input/temp_tables/temp_table.sql b/test/JDBC/input/temp_tables/temp_table.sql index 697ab44617..203436a6ed 100644 --- a/test/JDBC/input/temp_tables/temp_table.sql +++ b/test/JDBC/input/temp_tables/temp_table.sql @@ -1,3 +1,6 @@ +USE master +GO + -- BABEL-4912 test ALTER TABLE for temp tables CREATE TABLE #t1 (a INT IDENTITY PRIMARY KEY NOT NULL, b INT) GO @@ -163,3 +166,131 @@ GO DROP TABLE #t1 GO + +-- BABEL-4868 disallow the usage of user-defined functions in temp table column defaults (to prevent orphaned catalog entries) +CREATE FUNCTION temp_table_func1(@a INT) RETURNS INT AS BEGIN RETURN 1 END +GO + +-- normal tables should be ok +CREATE TABLE temp_table_t1(a INT DEFAULT temp_table_func1(5)) +GO + +INSERT INTO temp_table_t1 VALUES (DEFAULT) +GO + +SELECT * FROM temp_table_t1 +GO + +DROP TABLE temp_table_t1 +GO + +-- temp tables should not work +CREATE TABLE #t1 (a INT DEFAULT temp_table_func1(5)) +GO + +-- two and three part names should not work either +CREATE TABLE #t1 (a INT DEFAULT dbo.temp_table_func1(6)) +GO + +CREATE TABLE #t1 (a INT DEFAULT master.dbo.temp_table_func1(7)) +GO + +-- also block adding columns via ALTER TABLE +CREATE TABLE #t1 (a INT) +GO + +ALTER TABLE #t1 ADD b INT DEFAULT temp_table_func1(5) +GO + +DROP TABLE #t1 +GO + +-- same with table variables +DECLARE @tv TABLE (a INT DEFAULT temp_table_func1(5)) +INSERT INTO @tv VALUES (DEFAULT) +SELECT * FROM @tv +GO + +-- system functions such as ISJSON() should work +CREATE TABLE #t1 (a INT DEFAULT ISJSON('a')) +GO + +ALTER TABLE #t1 ADD b INT DEFAULT ISJSON('b') +GO + +INSERT INTO #t1 VALUES (DEFAULT, DEFAULT) +GO + +SELECT * FROM #t1 +GO + +DROP TABLE #t1 +GO + +DECLARE @tv TABLE (a INT DEFAULT ISJSON('a')) +INSERT INTO @tv VALUES (DEFAULT) +SELECT * FROM @tv +GO + +-- disallow "sys"-qualified function calls +CREATE TABLE #t1 (a INT DEFAULT SYS.ISJSON('a')) +GO + +-- disallow user-defined overrides for system functions +CREATE FUNCTION ISJSON(@json TEXT) RETURNS INT AS BEGIN RETURN 10 END +GO + +-- cannot use schema-qualified name +CREATE TABLE #t1 (a INT DEFAULT dbo.ISJSON('a')) +GO + +-- should work, default to using the system function +CREATE TABLE #t1 (a INT DEFAULT ISJSON('a')) +GO + +INSERT INTO #t1 VALUES (DEFAULT) +GO + +SELECT * FROM #t1 +GO + +DROP TABLE #t1 +GO + +-- Aggregate functions should not work +create table #t1(a int, b int default any_value(a)) +go + +create table #t1(a int, b int default any_value(1)) +go + +-- also validate that the restrictions work for ALTER TABLE ADD CONSTRAINT +CREATE TABLE #t1 (a INT) +GO + +-- user-defined functions should not work +ALTER TABLE #t1 ADD CONSTRAINT myconstraint DEFAULT temp_table_func1(5) FOR a +GO + +-- nor should system function overrides +ALTER TABLE #t1 ADD CONSTRAINT myconstraint DEFAULT dbo.ISJSON('a') FOR a +GO + +-- but system functions should still work +ALTER TABLE #t1 ADD CONSTRAINT myconstraint DEFAULT ISJSON('a') FOR a +GO + +INSERT INTO #t1 VALUES (DEFAULT) +GO + +SELECT * FROM #t1 +GO + +DROP TABLE #t1 +GO + +DROP FUNCTION dbo.ISJSON +GO + +DROP FUNCTION temp_table_func1 +GO diff --git a/test/JDBC/sql_expected/BABEL-IDENTITY.out b/test/JDBC/sql_expected/BABEL-IDENTITY.out index c2c76a9926..c47efad5fe 100644 --- a/test/JDBC/sql_expected/BABEL-IDENTITY.out +++ b/test/JDBC/sql_expected/BABEL-IDENTITY.out @@ -162,7 +162,7 @@ SET IDENTITY_INSERT dbo.test_table2 ON; go ~~ERROR (Code: 8107)~~ -~~ERROR (Message: IDENTITY_INSERT is already ON for table 'jdbc_testdb.master_dbo.test_table1')~~ +~~ERROR (Message: IDENTITY_INSERT is already ON for table 'babelfish_db.master_dbo.test_table1')~~ SET IDENTITY_INSERT dbo.test_table1 OFF; go diff --git a/test/JDBC/src/main/java/com/sqlsamples/JDBCTempTable.java b/test/JDBC/src/main/java/com/sqlsamples/JDBCTempTable.java index e6fb4b206f..078be67847 100644 --- a/test/JDBC/src/main/java/com/sqlsamples/JDBCTempTable.java +++ b/test/JDBC/src/main/java/com/sqlsamples/JDBCTempTable.java @@ -179,7 +179,7 @@ private static void test_oid_buffer(BufferedWriter bw, Logger logger) throws Exc * the OID buffer. */ Statement alter_guc = psql.createStatement(); - alter_guc.execute("ALTER DATABASE jdbc_testdb SET babelfishpg_tsql.temp_oid_buffer_size = 0"); + alter_guc.execute("ALTER DATABASE babelfish_db SET babelfishpg_tsql.temp_oid_buffer_size = 0"); if (check_oids_equal_helper(num_connections)) { bw.write("OID check failed! Oids were equal after disabling guc."); @@ -189,7 +189,7 @@ private static void test_oid_buffer(BufferedWriter bw, Logger logger) throws Exc /* * TEST: Ensure that we can create up to (and no more) than the oid buffer size. */ - alter_guc.execute("ALTER DATABASE jdbc_testdb SET babelfishpg_tsql.temp_oid_buffer_size = 3"); + alter_guc.execute("ALTER DATABASE babelfish_db SET babelfishpg_tsql.temp_oid_buffer_size = 3"); /* We need a new connection here to pick up the updated guc. */ Connection c2 = DriverManager.getConnection(connectionString); @@ -237,7 +237,7 @@ private static void test_oid_buffer(BufferedWriter bw, Logger logger) throws Exc c2.close(); /* Restore GUC after tests. */ - alter_guc.execute("ALTER DATABASE jdbc_testdb SET babelfishpg_tsql.temp_oid_buffer_size = 65536"); + alter_guc.execute("ALTER DATABASE babelfish_db SET babelfishpg_tsql.temp_oid_buffer_size = 65536"); psql.close(); c.close(); } diff --git a/test/JDBC/src/main/resources/config.txt b/test/JDBC/src/main/resources/config.txt index de548913b4..a88837b9aa 100644 --- a/test/JDBC/src/main/resources/config.txt +++ b/test/JDBC/src/main/resources/config.txt @@ -3,7 +3,7 @@ URL = localhost tsql_port = 1433 psql_port = 5432 databaseName = master -physicalDatabaseName = jdbc_testdb +physicalDatabaseName = babelfish_db user = jdbc_user password = 12345678 diff --git a/test/JDBC/upgrade/16_6/schedule b/test/JDBC/upgrade/16_6/schedule index f5cc36dbe8..5699e82ede 100644 --- a/test/JDBC/upgrade/16_6/schedule +++ b/test/JDBC/upgrade/16_6/schedule @@ -494,7 +494,6 @@ set_tran_isolvl with_recompile alter_proc_recompile catalogs_dbo_sys_schema-upgrade -unary_plus_op_string BABEL-4217 Test_ISNULL BABEL-4270 diff --git a/test/dotnet/ExpectedOutput/TestTvp.out b/test/dotnet/ExpectedOutput/TestTvp.out index 4884995318..dc024cc546 100644 --- a/test/dotnet/ExpectedOutput/TestTvp.out +++ b/test/dotnet/ExpectedOutput/TestTvp.out @@ -32,3 +32,115 @@ 1#!#1#!#1#!#1#!#True#!#hi #!#hi #!#hi#!#hi#!#4949#!#494900000000#!#10/10/2022 00:00:00#!#10/10/2022 10:10:10#!#143.5000#!#ce8af10a-2709-43b0-9e4e-a02753929d17#!#12.11#!#13.11#!#1.330#!#45.122#!#10:10:10#!#10/10/2022 10:10:10 #Q#drop type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong #Q#drop schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +#Q#create table t(a int) +#Q#create type t1 as table (a int) +#Q#create procedure proc1 @t2 as t1 readonly as begin set nocount on; insert into t (a) select a from @t2 end +#Q#proc1 +#Q#Select * from t +#D#int +5 +#Q#create table tab1(a int) +#Q#create schema test_tvp1 +#Q#create type test_tvp1.t1 as table (a int) +#Q#create procedure proc2 @t2 as test_tvp1.t1 readonly as begin set nocount on; insert into tab1 (a) select a from @t2 end +#Q#proc2 +#Q#Select * from tab1 +#D#int +5 +#Q#create table t2(a int) +#Q#create procedure test_tvp1.proc1 @t2 test_tvp1.t1 readonly as begin set nocount on; insert into t2 (a) select a from @t2 end +#Q#test_tvp1.proc1 +#Q#Select * from t2 +#D#int +5 +#Q#create table t3(a int) +#Q#create schema test_tvp2 +#Q#create procedure test_tvp2.proc2 @t2 as test_tvp1.t1 readonly as begin set nocount on; insert into t3 (a) select a from @t2 end +#Q#test_tvp2.proc2 +#Q#Select * from t3 +#D#int +5 +#Q#create table t4(a int) +#Q#create procedure test_tvp2.proc3 @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as t1 READONLY AS BEGIN insert into t4 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +#Q#test_tvp2.proc3 +#Q#Select * from t4 +#D#int +5 +#Q#create table t5(a int) +#Q#create type test_tvp2.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 as table (a int) +#Q#create procedure test_tvp2.proc4 @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as test_tvp2.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t5 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +#Q#test_tvp2.proc4 +#Q#Select * from t5 +#D#int +5 +#Q#create table t6(a int) +#Q#create schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +#Q#create type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 as table (a int) +#Q#create procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.proc5 @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t6 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +#Q#this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.proc5 +#Q#Select * from t6 +#D#int +5 +#Q#create table t7(a int) +#Q#create procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t7 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +#Q#this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +#Q#Select * from t7 +#D#int +5 +#Q#create table t10(a int) +#Q#create type tvp_type as table (a int) +#Q#create procedure proc7 @random int, @t2 tvp_type READONLY AS BEGIN insert into t10 select * from @t2 END +#Q#proc7 +#Q#Select * from t10 +#D#int +5 +#Q#drop procedure proc1 +#Q#drop procedure proc2 +#Q#drop procedure test_tvp1.proc1 +#Q#drop procedure test_tvp2.proc2 +#Q#drop procedure test_tvp2.proc3 +#Q#drop procedure test_tvp2.proc4 +#Q#drop procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.proc5 +#Q#drop procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +#Q#drop procedure proc7 +#Q#drop table t +#Q#drop table tab1 +#Q#drop table t2 +#Q#drop table t3 +#Q#drop table t4 +#Q#drop table t5 +#Q#drop table t6 +#Q#drop table t7 +#Q#drop table t10 +#Q#drop type t1 +#Q#drop type test_tvp1.t1 +#Q#drop type test_tvp2.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 +#Q#drop type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 +#Q#drop type tvp_type +#Q#drop schema test_tvp1 +#Q#drop schema test_tvp2 +#Q#drop schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +#Q#create database db1 +#Q#Use db1 +#Q#create table t8(a int) +#Q#create schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +#Q#create type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 as table (a int) +#Q#create procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t8 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +#Q#this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +#Q#Select * from t8 +#D#int +5 +#Q#create table t9(a int) +#Q#create procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong_new @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t9 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +#Q#db1.this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong_new +#Q#Select * from t9 +#D#int +5 +#Q#drop procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +#Q#drop procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong_new +#Q#drop table db1.dbo.t8 +#Q#drop table db1.dbo.t9 +#Q#drop type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 +#Q#drop schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +#Q#use master +#Q#drop database db1 diff --git a/test/dotnet/input/Datatypes/TestTvp.txt b/test/dotnet/input/Datatypes/TestTvp.txt index 01bc74f8a8..1a473c0ff5 100644 --- a/test/dotnet/input/Datatypes/TestTvp.txt +++ b/test/dotnet/input/Datatypes/TestTvp.txt @@ -20,6 +20,7 @@ Create table tvp_table(a int, b smallint, c bigint, d tinyint, e bit, f char(10) create type this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as table (a int, b smallint, c bigint, d tinyint, e bit, f char(10), g nchar(10), h varchar(10), i nvarchar(10), l varbinary(10), m binary(10), n date, o datetime, p money, q uniqueidentifier,r float, s real, t numeric(4,3), u decimal(5,3), v time(5), w datetime2(5)) create procedure tvp_proc @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong READONLY AS BEGIN insert into tvp_table select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END storedproc#!#prep#!#tvp_proc#!#tvp|-|this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-|this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-|../../../utils/tvp-dotnet.csv + Select * from tvp_table drop procedure tvp_proc drop table tvp_table @@ -30,4 +31,118 @@ create schema this_schema_name_is_also_very_looooooooooooooooooooooooooooooooooo create type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as table (a int, b smallint, c bigint, d tinyint, e bit, f char(10), g nchar(10), h varchar(10), i nvarchar(10), l varbinary(10), m binary(10), n date, o datetime, p money, q uniqueidentifier,r float, s real, t numeric(4,3), u decimal(5,3), v time(5), w datetime2(5)) prepst#!#Select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong#!#tvp|-|this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-|this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-|../../../utils/tvp-dotnet.csv drop type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong -drop schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong \ No newline at end of file +drop schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong + +#test tvp without passing tvpTypeName +create table t(a int) +create type t1 as table (a int) +create procedure proc1 @t2 as t1 readonly as begin set nocount on; insert into t (a) select a from @t2 end +storedproc#!#prep#!#proc1#!#tvp|-|t2|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t + +# test with schema for type and without passing tvpTypeName +create table tab1(a int) +create schema test_tvp1 +create type test_tvp1.t1 as table (a int) +create procedure proc2 @t2 as test_tvp1.t1 readonly as begin set nocount on; insert into tab1 (a) select a from @t2 end +storedproc#!#prep#!#proc2#!#tvp|-|t2|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from tab1 + +# test with schema for proc and type in same schema and without passing tvpTypeName +create table t2(a int) +create procedure test_tvp1.proc1 @t2 test_tvp1.t1 readonly as begin set nocount on; insert into t2 (a) select a from @t2 end +storedproc#!#prep#!#test_tvp1.proc1#!#tvp|-|t2|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t2 + +# test with schema for proc and type in different schema and without passing tvpTypeName +create table t3(a int) +create schema test_tvp2 +create procedure test_tvp2.proc2 @t2 as test_tvp1.t1 readonly as begin set nocount on; insert into t3 (a) select a from @t2 end +storedproc#!#prep#!#test_tvp2.proc2#!#tvp|-|t2|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t3 + +# executing stored proc without passing tvp value for huge parameter name and without passing tvpTypeName +create table t4(a int) +create procedure test_tvp2.proc3 @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as t1 READONLY AS BEGIN insert into t4 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +storedproc#!#prep#!#test_tvp2.proc3#!#tvp|-|this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t4 + +# when parameter and type both are very long, and both are part of schema other than dbo and without passing tvpTypeName +create table t5(a int) +create type test_tvp2.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 as table (a int) +create procedure test_tvp2.proc4 @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as test_tvp2.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t5 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +storedproc#!#prep#!#test_tvp2.proc4#!#tvp|-|this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t5 + +# when parameter and type both are very long, and both are part of a very long schema other than dbo and without passing tvpTypeName +create table t6(a int) +create schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +create type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 as table (a int) +create procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.proc5 @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t6 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +storedproc#!#prep#!#this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.proc5#!#tvp|-|this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t6 + +# when parameter, type, schema and procedure name are very long and without passing tvpTypeName +create table t7(a int) +create procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t7 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +storedproc#!#prep#!#this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong#!#tvp|-|this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t7 + +# procedure having multiple args, without passing tvp tvpTypeName +create table t10(a int) +create type tvp_type as table (a int) +create procedure proc7 @random int, @t2 tvp_type READONLY AS BEGIN insert into t10 select * from @t2 END +storedproc#!#prep#!#proc7#!#int|-|random|-|20|-|input#!#tvp|-|t2|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t10 + +drop procedure proc1 +drop procedure proc2 +drop procedure test_tvp1.proc1 +drop procedure test_tvp2.proc2 +drop procedure test_tvp2.proc3 +drop procedure test_tvp2.proc4 +drop procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.proc5 +drop procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +drop procedure proc7 +drop table t +drop table tab1 +drop table t2 +drop table t3 +drop table t4 +drop table t5 +drop table t6 +drop table t7 +drop table t10 +drop type t1 +drop type test_tvp1.t1 +drop type test_tvp2.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 +drop type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 +drop type tvp_type +drop schema test_tvp1 +drop schema test_tvp2 +drop schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong + +# creating a db and creating objects in it and executing the proc without db specification +create database db1 +Use db1 +create table t8(a int) +create schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +create type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 as table (a int) +create procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t8 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +storedproc#!#prep#!#this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong#!#tvp|-|this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t8 + +# creating a db and creating objects in it and executing the proc with db specification +create table t9(a int) +create procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong_new @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong as this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 READONLY AS BEGIN insert into t9 select * from @this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong END +storedproc#!#prep#!#db1.this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong_new#!#tvp|-|this_tvp_parameter_name_is_very_loooooooooooooooooooooooooooooooooooooooooong|-| |-|../../../utils/tvp-test-dotnet.csv +Select * from t9 + +drop procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +drop procedure this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_proc_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong_new +drop table db1.dbo.t8 +drop table db1.dbo.t9 +drop type this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong.this_tvp_type_name_is_very_loooooooooooooooooooooooooooooooooooooooooong5 +drop schema this_schema_name_is_also_very_loooooooooooooooooooooooooooooooooooooooooong +use master +drop database db1 diff --git a/test/dotnet/utils/tvp-test-dotnet.csv b/test/dotnet/utils/tvp-test-dotnet.csv new file mode 100644 index 0000000000..e795f11e97 --- /dev/null +++ b/test/dotnet/utils/tvp-test-dotnet.csv @@ -0,0 +1,2 @@ +a-int +5 diff --git a/test/python/SMO_script.ps1 b/test/python/SMO_script.ps1 index 568e4425d7..ce76a6bdbb 100644 --- a/test/python/SMO_script.ps1 +++ b/test/python/SMO_script.ps1 @@ -63,7 +63,7 @@ if($script_flag -eq $var_one) # Scripting standard database objects. foreach ($CurrentObject in $Objects) { - if (-not $CurrentObject.IsSystemObject ) + if ($CurrentObject.schema -ne $schm -and -not $CurrentObject.IsSystemObject ) { $Scripter.Script($CurrentObject); Write-Output "GO`n"