diff --git a/.gitattributes b/.gitattributes index 200ee40..1cc4ca2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,16 +1,13 @@ dependencies.md linguist-generated=true doc/changes/changelog.md linguist-generated=true pk_generated_parent.pom linguist-generated=true -.github/workflows/ci-build.yml linguist-generated=true .github/workflows/broken_links_checker.yml linguist-generated=true +.github/workflows/ci-build.yml linguist-generated=true .github/workflows/ci-build-next-java.yml linguist-generated=true .github/workflows/dependencies_check.yml linguist-generated=true -.github/workflows/release_droid_prepare_original_checksum.yml linguist-generated=true -.github/workflows/release_droid_print_quick_checksum.yml linguist-generated=true -.github/workflows/release_droid_release_on_maven_central.yml linguist-generated=true -.github/workflows/release_droid_upload_github_release_assets.yml linguist-generated=true +.github/workflows/dependencies_update.yml linguist-generated=true +.github/workflows/release.yml linguist-generated=true .settings/org.eclipse.jdt.core.prefs linguist-generated=true .settings/org.eclipse.jdt.ui.prefs linguist-generated=true - .settings/org.eclipse.jdt.core.prefs linguist-generated=true .settings/org.eclipse.jdt.ui.prefs linguist-generated=true diff --git a/.github/workflows/broken_links_checker.yml b/.github/workflows/broken_links_checker.yml index 0fbcad5..d7a38b4 100644 --- a/.github/workflows/broken_links_checker.yml +++ b/.github/workflows/broken_links_checker.yml @@ -13,6 +13,9 @@ on: jobs: linkChecker: runs-on: ubuntu-latest + defaults: + run: + shell: "bash" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/ci-build-next-java.yml b/.github/workflows/ci-build-next-java.yml index e3acdb7..8886e10 100644 --- a/.github/workflows/ci-build-next-java.yml +++ b/.github/workflows/ci-build-next-java.yml @@ -10,6 +10,12 @@ on: jobs: java-17-compatibility: runs-on: ubuntu-latest + defaults: + run: + shell: "bash" + permissions: + contents: read + checks: write # Allow scacap/action-surefire-report concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index fd65a06..e847dc0 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -3,20 +3,25 @@ name: CI Build on: push: - branches: - - main + branches: ["main"] pull_request: jobs: matrix-build: runs-on: ubuntu-20.04 + defaults: + run: + shell: "bash" + permissions: + contents: read + checks: write # Allow scacap/action-surefire-report concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.exasol_db_version }} cancel-in-progress: true strategy: fail-fast: false matrix: - exasol_db_version: ["7.1.25"] + exasol_db_version: ["7.1.25", "8.24.0"] env: DEFAULT_EXASOL_DB_VERSION: "7.1.25" steps: @@ -38,7 +43,7 @@ jobs: 17 cache: "maven" - name: Cache SonarCloud packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar @@ -46,6 +51,7 @@ jobs: - name: Enable testcontainer reuse run: echo 'testcontainers.reuse.enable=true' > "$HOME/.testcontainers.properties" - name: Run tests and build with Maven + id: pk-verify run: | mvn --batch-mode clean verify \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ @@ -71,8 +77,58 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - name: Verify Release Artifacts + run: | + print_message() { + local -r message=$1 + echo "$message" + echo "$message" >> "$GITHUB_STEP_SUMMARY" + } + + print_message "# Release Artifacts" + + IFS=$'\n' artifacts_array=($ARTIFACTS) + missing_files=() + for file in "${artifacts_array[@]}"; + do + echo "Checking if file $file exists..." + if ! [[ -f "$file" ]]; then + print_message "* ⚠️ \`$file\` does not exist ⚠️" + echo "Content of directory $(dirname "$file"):" + ls "$(dirname "$file")" + missing_files+=("$file") + else + print_message "* \`$file\` ✅" + fi + done + print_message "" + number_of_missing_files=${#missing_files[@]} + if [[ $number_of_missing_files -gt 0 ]]; then + print_message "⚠️ $number_of_missing_files release artifact(s) missing ⚠️" + exit 1 + else + print_message "All ${#artifacts_array[@]} artifact(s) present ✅" + fi + env: + ARTIFACTS: ${{ steps.pk-verify.outputs.release-artifacts }} + build: needs: matrix-build runs-on: ubuntu-latest steps: - run: echo "Build successful" + + # [impl->dsn~release-workflow.ci-build-starts-release~1] + start_release: + needs: build + if: ${{ github.ref == 'refs/heads/main' }} + concurrency: + cancel-in-progress: false + group: "release" + secrets: inherit + permissions: + contents: write + actions: read + uses: ./.github/workflows/release.yml + with: + started-from-ci: true diff --git a/.github/workflows/dependencies_check.yml b/.github/workflows/dependencies_check.yml index 87b64ba..bd26ab6 100644 --- a/.github/workflows/dependencies_check.yml +++ b/.github/workflows/dependencies_check.yml @@ -1,6 +1,6 @@ # Generated by Project Keeper # https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/dependencies_check.yml -name: Report Security Issues for Repository +name: Report Security Issues on: workflow_dispatch: schedule: @@ -9,11 +9,17 @@ on: jobs: report_security_issues: runs-on: ubuntu-latest + defaults: + run: + shell: "bash" permissions: + contents: read issues: write - + outputs: + created-issues: ${{ steps.security-issues.outputs.created-issues }} steps: - uses: actions/checkout@v4 + - name: Set up JDKs uses: actions/setup-java@v4 with: @@ -25,14 +31,38 @@ jobs: - name: Generate ossindex report run: | - mvn org.sonatype.ossindex.maven:ossindex-maven-plugin:audit \ + mvn --batch-mode org.sonatype.ossindex.maven:ossindex-maven-plugin:audit \ org.sonatype.ossindex.maven:ossindex-maven-plugin:audit-aggregate \ -Dossindex.reportFile=$(pwd)/ossindex-report.json \ -Dossindex.fail=false - name: Report Security Issues + id: security-issues uses: exasol/python-toolbox/.github/actions/security-issues@main with: format: "maven" command: "cat ossindex-report.json" github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Output security issues (Debugging) + run: | + echo "$CREATED_ISSUES" > test.jsonl + cat test.jsonl + env: + CREATED_ISSUES: ${{ steps.security-issues.outputs.created-issues }} + + start_dependency_udpate: + needs: report_security_issues + # [impl->dsn~trigger-dependency-updates~1] + if: ${{ needs.report_security_issues.outputs.created-issues }} + concurrency: + cancel-in-progress: true + group: "dependencies_update" + # Workflow needs secret INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK + secrets: inherit + permissions: + contents: write + pull-requests: write + uses: ./.github/workflows/dependencies_update.yml + with: + vulnerability_issues: ${{ needs.report_security_issues.outputs.created-issues }} diff --git a/.github/workflows/dependencies_update.yml b/.github/workflows/dependencies_update.yml new file mode 100644 index 0000000..0f6b816 --- /dev/null +++ b/.github/workflows/dependencies_update.yml @@ -0,0 +1,175 @@ +# Generated by Project Keeper +# https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/dependencies_update.yml +name: Update dependencies +on: + workflow_call: + inputs: + # [impl->dsn~dependency-updater.workflow.vulnerability-info~1] + vulnerability_issues: + description: "GitHub issues for vulnerable dependencies as JSONL" + required: true + type: string + workflow_dispatch: + +jobs: + update_dependencies: + runs-on: ubuntu-latest + defaults: + run: + shell: "bash" + permissions: + contents: write + pull-requests: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDKs + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: | + 11 + 17 + cache: "maven" + + - name: Print issues + run: | + echo "Issues from Action input: $ISSUES" + env: + ISSUES: ${{ inputs.vulnerability_issues }} + + - name: Fail if not running on a branch + if: ${{ !startsWith(github.ref, 'refs/heads/') }} + uses: actions/github-script@v7 + with: + script: | + core.setFailed('Not running on a branch, github.ref is ${{ github.ref }}. Please start this workflow only on main or a branch') + + - name: Update dependencies + # [impl->dsn~dependency-updater.workflow.start-pk-update~1] + run: | + mvn --batch-mode com.exasol:project-keeper-maven-plugin:update-dependencies --projects . \ + -Dproject-keeper:vulnerabilities="$CREATED_ISSUES" + env: + CREATED_ISSUES: ${{ inputs.vulnerability_issues }} + + - name: Project Keeper Fix + run: | + mvn --batch-mode com.exasol:project-keeper-maven-plugin:fix --projects . + + - name: Project Keeper Fix for updated Project Keeper version + # Calling PK fix a second time is necessary because the first invocation potentially updated PK itself. + # So we need to run PK fix again with the latest PK version. + # [impl->dsn~dependency-updater.workflow.start-pk-fix~1] + run: | + mvn --batch-mode com.exasol:project-keeper-maven-plugin:fix --projects . + + - name: Generate Pull Request comment + id: pr-comment + # [impl->dsn~dependency-updater.workflow.create-pull-request~1] + # [impl->dsn~dependency-updater.workflow.pull-request-trigger-ci-build~1] + run: | + echo 'comment<> "$GITHUB_OUTPUT" + echo 'This Pull Request was created by [`dependencies_update.yml`](https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/dependencies_update.yml) workflow.' >> "$GITHUB_OUTPUT" + if [ -n "$CREATED_ISSUES" ]; then + echo 'It updates dependencies to fix the following vulnerabilities:' >> "$GITHUB_OUTPUT" + echo $CREATED_ISSUES | jq --raw-output '. | "* Closes " + .issue_url + " (" + .cve + ")"' >> "$GITHUB_OUTPUT" + else + echo 'It updates dependencies.' >> "$GITHUB_OUTPUT" + fi + echo >> "$GITHUB_OUTPUT" + echo '# ⚠️ This PR does not trigger CI workflows by default ⚠️' >> "$GITHUB_OUTPUT" + echo 'Please click the **Close pull request** button and then **Reopen pull request** to trigger running checks.' >> "$GITHUB_OUTPUT" + echo 'See https://github.com/exasol/project-keeper/issues/534 for details.' >> "$GITHUB_OUTPUT" + echo 'EOF' >> "$GITHUB_OUTPUT" + + cat "$GITHUB_OUTPUT" + env: + CREATED_ISSUES: ${{ inputs.vulnerability_issues }} + + - name: Generate Pull Request Title + id: pr-title + run: | + if [ -n "$CREATED_ISSUES" ]; then + echo "Security issues are available" + echo "title=🔐 Update dependencies to fix vulnerabilities" >> "$GITHUB_OUTPUT" + else + echo "Security issues are not available" + echo "title=Update dependencies" >> "$GITHUB_OUTPUT" + fi + + cat "$GITHUB_OUTPUT" + env: + CREATED_ISSUES: ${{ inputs.vulnerability_issues }} + + - name: Configure git + run: | + git config --global user.email "opensource@exasol.com" + git config --global user.name "Automatic Dependency Updater" + + - name: Create branch + if: ${{ github.ref == 'refs/heads/main' }} + run: | + branch_name="dependency-update/$(date "+%Y%m%d%H%M%S")" + echo "Creating branch $branch_name" + git checkout -b "$branch_name" + + - name: Commit changes & push + if: ${{ startsWith(github.ref, 'refs/heads/' ) }} + run: | + branch_name=$(git rev-parse --abbrev-ref HEAD) + echo "Current branch: $branch_name" + echo "git diff --stat" + git diff --stat + echo "git diff --numstat" + git diff --numstat + echo "git diff --name-status" + git diff --name-status + echo "Adding untracked files:" + git add . --verbose --all + echo "Committing changes..." + git commit --message "$TITLE" + echo "Pushing branch $branch_name..." + git push --set-upstream origin "$branch_name" + echo "Done." + env: + TITLE: ${{ steps.pr-title.outputs.title }} + + - name: Create pull request + id: create-pr + if: ${{ github.ref == 'refs/heads/main' }} + run: | + pr_url=$(gh pr create --base main --title "$TITLE" --body "$COMMENT") + echo "Created Pull Request: $pr_url" + echo "pr_url=$pr_url" >> "$GITHUB_OUTPUT" + env: + COMMENT: ${{ steps.pr-comment.outputs.comment }} + TITLE: ${{ steps.pr-title.outputs.title }} + GH_TOKEN: ${{ github.token }} + + - name: Report failure Status to Slack channel + # Also run this step in case of failures + if: ${{ always() }} + uses: ravsamhq/notify-slack-action@v2 + with: + status: ${{ job.status }} + token: ${{ secrets.GITHUB_TOKEN }} + notification_title: "Dependency check in {repo} has {status_message}" + message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" + notify_when: "failure,cancelled,warnings" + env: + SLACK_WEBHOOK_URL: ${{ secrets.INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK }} + + - name: Report new Pull Request to Slack channel + if: ${{ steps.create-pr.outputs.pr_url }} + uses: ravsamhq/notify-slack-action@v2 + with: + status: ${{ job.status }} + token: ${{ secrets.GITHUB_TOKEN }} + notification_title: "Dependency update for {repo} created a Pull Request" + message_format: "{workflow} created Pull Request ${{ steps.create-pr.outputs.pr_url }}" + env: + SLACK_WEBHOOK_URL: ${{ secrets.INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fe959c9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,193 @@ +# Generated by Project Keeper +# https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/release.yml +name: Release +on: + # [impl->dsn~release-workflow.triggers~1] + workflow_call: + inputs: + started-from-ci: + description: "Marks this release as started from CI, skipping precondition check" + type: boolean + required: true + default: false + workflow_dispatch: + inputs: + skip-maven-central: + description: "Skip deployment to Maven Central" + required: true + type: boolean + default: false + skip-github-release: + description: "Skip creating the GitHub release" + required: true + type: boolean + default: false + +jobs: + release: + runs-on: ubuntu-latest + defaults: + run: + shell: "bash" + concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + permissions: + contents: write + actions: read + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Maven Central Repository + if: ${{ true }} + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: | + 11 + 17 + cache: "maven" + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Set up JDKs + if: ${{ ! true }} + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: | + 11 + 17 + cache: "maven" + + # Check preconditions + + - name: Fail if not running on main branch + if: ${{ github.ref != 'refs/heads/main' }} + uses: actions/github-script@v7 + with: + script: | + core.setFailed('Not running on main branch, github.ref is ${{ github.ref }}. Please start this workflow only on main') + + # [impl->dsn~release-workflow.verify-ci-build-success~1] + - name: Check CI build of this commit succeeded + # We skip this check if this was started from ci-build.yml, because the build status would be "in progress". + if: ${{ ! inputs.started-from-ci }} + run: | + echo "Commit SHA: $COMMIT_SHA" + gh run list --workflow ci-build.yml --branch main --event push --commit $COMMIT_SHA + ci_build_status=$(gh run list --workflow ci-build.yml --branch main --event push --commit $COMMIT_SHA --json conclusion --template '{{range .}}{{.conclusion}}{{"\n"}}{{end}}') + echo "CI build status at commit $COMMIT_SHA was '$ci_build_status'" + if [[ "$ci_build_status" != "success" ]]; then + gh run list --workflow ci-build.yml --commit $COMMIT_SHA >> $GITHUB_STEP_SUMMARY + echo "Status of CI build for commit $COMMIT_SHA was '$ci_build_status', expected 'success'" >> $GITHUB_STEP_SUMMARY + cat $GITHUB_STEP_SUMMARY + exit 1 + fi + env: + COMMIT_SHA: ${{ github.sha }} + GH_TOKEN: ${{ github.token }} + # [impl->dsn~release-workflow.run-verify-release~1] + - name: Verify release preconditions + id: verify-release + run: | + mvn --batch-mode com.exasol:project-keeper-maven-plugin:verify-release --projects . + echo "$GITHUB_OUTPUT" + env: + GITHUB_TOKEN: ${{ github.token }} + # [impl->dsn~release-workflow.verify-skip-tests~1] + - name: Build project + run: mvn --batch-mode -DskipTests clean verify + + # Maven Central Deployment + - name: List secret GPG keys + if: ${{ true && (! inputs.skip-maven-central) }} + run: gpg --list-secret-keys + # [impl->dsn~release-workflow.deploy-maven-central~1] + - name: Publish to Central Repository + if: ${{ true && (! inputs.skip-maven-central) }} + run: | + mvn --batch-mode -Dgpg.skip=false -DskipTests deploy + echo "Published to Maven Central" >> "$GITHUB_STEP_SUMMARY" + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + + # Create GitHub releasse + + - name: Calculate Artifact Checksums + id: artifact-checksum + if: ${{ ! inputs.skip-github-release }} + run: | + ls target/ + echo "Calculating sha256 checksum for artifact files" + echo "artifacts<> "$GITHUB_OUTPUT" + IFS=$'\n' artifacts_array=($ARTIFACTS) + for file in "${artifacts_array[@]}"; + do + full_path=$(realpath "$file") + echo "Calculate sha256sum for file '$full_path'" + file_dir="$(dirname "$full_path")" + file_name=$(basename "$full_path") + pushd "$file_dir" + checksum_file_name="${file_name}.sha256" + sha256sum "$file_name" > "$checksum_file_name" + echo "$full_path" >> "$GITHUB_OUTPUT" + echo "${file_dir}/$checksum_file_name" >> "$GITHUB_OUTPUT" + popd + done + echo "EOF" >> "$GITHUB_OUTPUT" + echo "Full artifact file list" + cat "$GITHUB_OUTPUT" + env: + ARTIFACTS: ${{ steps.verify-release.outputs.release-artifacts }} + + # [impl->dsn~release-workflow.create-github-release~1] + - name: Create GitHub Release + id: create-github-release + if: ${{ ! inputs.skip-github-release }} + run: | + IFS=$'\n' artifacts_array=($ARTIFACTS) + for file in "${artifacts_array[@]}"; + do + echo "Attaching file '$file'" + done + release_url=$(gh release create --draft --latest --title "$TITLE" --notes "$NOTES" --target main $TAG "${artifacts_array[@]}") + echo "Created release $TAG with title '$TITLE' at $release_url" >> "$GITHUB_STEP_SUMMARY" + echo "release-url=$release_url" >> "$GITHUB_OUTPUT" + git fetch --tags origin + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ steps.verify-release.outputs.version }} + NOTES: ${{ steps.verify-release.outputs.release-notes }} + TITLE: ${{ steps.verify-release.outputs.release-title }} + ARTIFACTS: ${{ steps.artifact-checksum.outputs.artifacts }} + + - name: Report failure Status to Slack channel + # Also run this step in case of failures + if: ${{ always() }} + uses: ravsamhq/notify-slack-action@v2 + with: + status: ${{ job.status }} + token: ${{ github.token }} + notification_title: "Release build in {repo} has {status_message}" + message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" + notify_when: "failure,cancelled,warnings,skipped" + env: + SLACK_WEBHOOK_URL: ${{ secrets.INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK }} + + - name: Report new release to Slack channel + if: ${{ steps.create-github-release.outputs.release-url }} + uses: ravsamhq/notify-slack-action@v2 + with: + status: ${{ job.status }} + token: ${{ github.token }} + notification_title: "Release build for {repo} created a new release" + message_format: "{workflow} created release ${{ steps.create-github-release.outputs.release-url }}" + env: + SLACK_WEBHOOK_URL: ${{ secrets.INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK }} diff --git a/.github/workflows/release_droid_prepare_original_checksum.yml b/.github/workflows/release_droid_prepare_original_checksum.yml deleted file mode 100644 index 413274b..0000000 --- a/.github/workflows/release_droid_prepare_original_checksum.yml +++ /dev/null @@ -1,39 +0,0 @@ -# Generated by Project Keeper -# https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/release_droid_prepare_original_checksum.yml -name: Release Droid - Prepare Original Checksum -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - name: Free Disk Space - if: ${{ false }} - run: | - sudo rm -rf /usr/local/lib/android - sudo rm -rf /usr/share/dotnet - - name: Checkout the repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up JDKs - uses: actions/setup-java@v4 - with: - distribution: "temurin" - java-version: | - 11 - 17 - cache: "maven" - - name: Enable testcontainer reuse - run: echo 'testcontainers.reuse.enable=true' > "$HOME/.testcontainers.properties" - - name: Run tests and build with Maven - run: mvn --batch-mode clean verify --file pom.xml - - name: Prepare checksum - run: find target -maxdepth 1 -name *.jar -exec sha256sum "{}" + > original_checksum - - name: Upload checksum to the artifactory - uses: actions/upload-artifact@v3 - with: - name: original_checksum - retention-days: 5 - path: original_checksum diff --git a/.github/workflows/release_droid_print_quick_checksum.yml b/.github/workflows/release_droid_print_quick_checksum.yml deleted file mode 100644 index 86979cd..0000000 --- a/.github/workflows/release_droid_print_quick_checksum.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Project Keeper -# https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/release_droid_print_quick_checksum.yml -name: Release Droid - Print Quick Checksum -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up JDKs - uses: actions/setup-java@v4 - with: - distribution: "temurin" - java-version: | - 11 - 17 - cache: "maven" - - name: Build with Maven skipping tests - run: mvn --batch-mode clean verify -DskipTests - - name: Print checksum - run: echo 'checksum_start==';find target -maxdepth 1 -name *.jar -exec sha256sum "{}" + | xargs;echo '==checksum_end' diff --git a/.github/workflows/release_droid_release_on_maven_central.yml b/.github/workflows/release_droid_release_on_maven_central.yml deleted file mode 100644 index 51d0659..0000000 --- a/.github/workflows/release_droid_release_on_maven_central.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Generated by Project Keeper -# https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/release_droid_release_on_maven_central.yml -name: Release Droid - Release On Maven Central -on: - workflow_dispatch: - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Maven Central Repository - uses: actions/setup-java@v4 - with: - distribution: "temurin" - java-version: | - 11 - 17 - cache: "maven" - server-id: ossrh - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} - gpg-passphrase: MAVEN_GPG_PASSPHRASE - - name: Publish to Central Repository - run: mvn --batch-mode -Dgpg.skip=false -DskipTests clean deploy - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} diff --git a/.github/workflows/release_droid_upload_github_release_assets.yml b/.github/workflows/release_droid_upload_github_release_assets.yml deleted file mode 100644 index b19f7cf..0000000 --- a/.github/workflows/release_droid_upload_github_release_assets.yml +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by Project Keeper -# https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/release_droid_upload_github_release_assets.yml -name: Release Droid - Upload GitHub Release Assets -on: - workflow_dispatch: - inputs: - upload_url: - description: "Assets upload URL" - required: true - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up JDKs - uses: actions/setup-java@v4 - with: - distribution: "temurin" - java-version: | - 11 - 17 - cache: "maven" - - name: Build with Maven skipping tests - run: mvn --batch-mode clean verify -DskipTests - - name: Generate sha256sum files - run: | - cd target - find . -maxdepth 1 -name \*.jar -exec bash -c 'sha256sum {} > {}.sha256' \; - - name: Upload assets to the GitHub release draft - uses: shogo82148/actions-upload-release-asset@v1 - with: - upload_url: ${{ github.event.inputs.upload_url }} - asset_path: target/*.jar - - name: Upload sha256sum files - uses: shogo82148/actions-upload-release-asset@v1 - with: - upload_url: ${{ github.event.inputs.upload_url }} - asset_path: target/*.sha256 - - name: Upload error-code-report - uses: shogo82148/actions-upload-release-asset@v1 - with: - upload_url: ${{ github.event.inputs.upload_url }} - asset_path: target/error_code_report.json diff --git a/.project-keeper.yml b/.project-keeper.yml index 927a60e..478bded 100644 --- a/.project-keeper.yml +++ b/.project-keeper.yml @@ -8,5 +8,7 @@ sources: - maven_central build: runnerOs: ubuntu-20.04 + freeDiskSpace: false exasolDbVersions: - "7.1.25" + - "8.24.0" diff --git a/.vscode/settings.json b/.vscode/settings.json index 58dfe90..ec60dc8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,5 +17,6 @@ "sonarlint.connectedMode.project": { "connectionId": "exasol", "projectKey": "com.exasol:exasol-virtual-schema" - } -} + }, + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/dependencies.md b/dependencies.md index 4bd24ae..ed5e48a 100644 --- a/dependencies.md +++ b/dependencies.md @@ -23,35 +23,36 @@ | [SLF4J JDK14 Provider][18] | [MIT License][19] | | [Test Database Builder for Java][20] | [MIT License][21] | | [Maven Project Version Getter][22] | [MIT License][23] | -| [JaCoCo :: Agent][24] | [Eclipse Public License 2.0][25] | +| [udf-debugging-java][24] | [MIT License][25] | +| [JaCoCo :: Agent][26] | [Eclipse Public License 2.0][27] | ## Plugin Dependencies | Dependency | License | | ------------------------------------------------------- | --------------------------------- | -| [SonarQube Scanner for Maven][26] | [GNU LGPL 3][27] | -| [Apache Maven Toolchains Plugin][28] | [Apache License, Version 2.0][29] | -| [Project Keeper Maven plugin][30] | [The MIT License][31] | -| [Apache Maven Compiler Plugin][32] | [Apache-2.0][29] | -| [Apache Maven Enforcer Plugin][33] | [Apache-2.0][29] | -| [Maven Flatten Plugin][34] | [Apache Software Licenese][29] | -| [org.sonatype.ossindex.maven:ossindex-maven-plugin][35] | [ASL2][36] | -| [Maven Surefire Plugin][37] | [Apache-2.0][29] | -| [Versions Maven Plugin][38] | [Apache License, Version 2.0][29] | -| [duplicate-finder-maven-plugin Maven Mojo][39] | [Apache License 2.0][40] | -| [Apache Maven Assembly Plugin][41] | [Apache-2.0][29] | -| [Apache Maven JAR Plugin][42] | [Apache License, Version 2.0][29] | -| [Artifact reference checker and unifier][43] | [MIT][11] | -| [Apache Maven Deploy Plugin][44] | [Apache-2.0][29] | -| [Apache Maven GPG Plugin][45] | [Apache-2.0][29] | -| [Apache Maven Source Plugin][46] | [Apache License, Version 2.0][29] | -| [Apache Maven Javadoc Plugin][47] | [Apache License, Version 2.0][29] | -| [Nexus Staging Maven Plugin][48] | [Eclipse Public License][49] | -| [Apache Maven Dependency Plugin][50] | [Apache-2.0][29] | -| [Maven Failsafe Plugin][51] | [Apache-2.0][29] | -| [JaCoCo :: Maven Plugin][52] | [Eclipse Public License 2.0][25] | -| [error-code-crawler-maven-plugin][53] | [MIT License][54] | -| [Reproducible Build Maven Plugin][55] | [Apache 2.0][36] | +| [SonarQube Scanner for Maven][28] | [GNU LGPL 3][29] | +| [Apache Maven Toolchains Plugin][30] | [Apache License, Version 2.0][31] | +| [Project Keeper Maven plugin][32] | [The MIT License][33] | +| [Apache Maven Compiler Plugin][34] | [Apache-2.0][31] | +| [Apache Maven Enforcer Plugin][35] | [Apache-2.0][31] | +| [Maven Flatten Plugin][36] | [Apache Software Licenese][31] | +| [org.sonatype.ossindex.maven:ossindex-maven-plugin][37] | [ASL2][38] | +| [Maven Surefire Plugin][39] | [Apache-2.0][31] | +| [Versions Maven Plugin][40] | [Apache License, Version 2.0][31] | +| [duplicate-finder-maven-plugin Maven Mojo][41] | [Apache License 2.0][42] | +| [Apache Maven Assembly Plugin][43] | [Apache-2.0][31] | +| [Apache Maven JAR Plugin][44] | [Apache License, Version 2.0][31] | +| [Artifact reference checker and unifier][45] | [MIT][11] | +| [Apache Maven Deploy Plugin][46] | [Apache-2.0][31] | +| [Apache Maven GPG Plugin][47] | [Apache-2.0][31] | +| [Apache Maven Source Plugin][48] | [Apache License, Version 2.0][31] | +| [Apache Maven Javadoc Plugin][49] | [Apache-2.0][31] | +| [Nexus Staging Maven Plugin][50] | [Eclipse Public License][51] | +| [Apache Maven Dependency Plugin][52] | [Apache-2.0][31] | +| [Maven Failsafe Plugin][53] | [Apache-2.0][31] | +| [JaCoCo :: Maven Plugin][54] | [Eclipse Public License 2.0][27] | +| [error-code-crawler-maven-plugin][55] | [MIT License][56] | +| [Reproducible Build Maven Plugin][57] | [Apache 2.0][38] | [0]: https://github.com/exasol/virtual-schema-common-jdbc/ [1]: https://github.com/exasol/virtual-schema-common-jdbc/blob/main/LICENSE @@ -77,35 +78,37 @@ [21]: https://github.com/exasol/test-db-builder-java/blob/main/LICENSE [22]: https://github.com/exasol/maven-project-version-getter/ [23]: https://github.com/exasol/maven-project-version-getter/blob/main/LICENSE -[24]: https://www.eclemma.org/jacoco/index.html -[25]: https://www.eclipse.org/legal/epl-2.0/ -[26]: http://sonarsource.github.io/sonar-scanner-maven/ -[27]: http://www.gnu.org/licenses/lgpl.txt -[28]: https://maven.apache.org/plugins/maven-toolchains-plugin/ -[29]: https://www.apache.org/licenses/LICENSE-2.0.txt -[30]: https://github.com/exasol/project-keeper/ -[31]: https://github.com/exasol/project-keeper/blob/main/LICENSE -[32]: https://maven.apache.org/plugins/maven-compiler-plugin/ -[33]: https://maven.apache.org/enforcer/maven-enforcer-plugin/ -[34]: https://www.mojohaus.org/flatten-maven-plugin/ -[35]: https://sonatype.github.io/ossindex-maven/maven-plugin/ -[36]: http://www.apache.org/licenses/LICENSE-2.0.txt -[37]: https://maven.apache.org/surefire/maven-surefire-plugin/ -[38]: https://www.mojohaus.org/versions/versions-maven-plugin/ -[39]: https://basepom.github.io/duplicate-finder-maven-plugin -[40]: http://www.apache.org/licenses/LICENSE-2.0.html -[41]: https://maven.apache.org/plugins/maven-assembly-plugin/ -[42]: https://maven.apache.org/plugins/maven-jar-plugin/ -[43]: https://github.com/exasol/artifact-reference-checker-maven-plugin -[44]: https://maven.apache.org/plugins/maven-deploy-plugin/ -[45]: https://maven.apache.org/plugins/maven-gpg-plugin/ -[46]: https://maven.apache.org/plugins/maven-source-plugin/ -[47]: https://maven.apache.org/plugins/maven-javadoc-plugin/ -[48]: http://www.sonatype.com/public-parent/nexus-maven-plugins/nexus-staging/nexus-staging-maven-plugin/ -[49]: http://www.eclipse.org/legal/epl-v10.html -[50]: https://maven.apache.org/plugins/maven-dependency-plugin/ -[51]: https://maven.apache.org/surefire/maven-failsafe-plugin/ -[52]: https://www.jacoco.org/jacoco/trunk/doc/maven.html -[53]: https://github.com/exasol/error-code-crawler-maven-plugin/ -[54]: https://github.com/exasol/error-code-crawler-maven-plugin/blob/main/LICENSE -[55]: http://zlika.github.io/reproducible-build-maven-plugin +[24]: https://github.com/exasol/udf-debugging-java/ +[25]: https://github.com/exasol/udf-debugging-java/blob/main/LICENSE +[26]: https://www.eclemma.org/jacoco/index.html +[27]: https://www.eclipse.org/legal/epl-2.0/ +[28]: http://sonarsource.github.io/sonar-scanner-maven/ +[29]: http://www.gnu.org/licenses/lgpl.txt +[30]: https://maven.apache.org/plugins/maven-toolchains-plugin/ +[31]: https://www.apache.org/licenses/LICENSE-2.0.txt +[32]: https://github.com/exasol/project-keeper/ +[33]: https://github.com/exasol/project-keeper/blob/main/LICENSE +[34]: https://maven.apache.org/plugins/maven-compiler-plugin/ +[35]: https://maven.apache.org/enforcer/maven-enforcer-plugin/ +[36]: https://www.mojohaus.org/flatten-maven-plugin/ +[37]: https://sonatype.github.io/ossindex-maven/maven-plugin/ +[38]: http://www.apache.org/licenses/LICENSE-2.0.txt +[39]: https://maven.apache.org/surefire/maven-surefire-plugin/ +[40]: https://www.mojohaus.org/versions/versions-maven-plugin/ +[41]: https://basepom.github.io/duplicate-finder-maven-plugin +[42]: http://www.apache.org/licenses/LICENSE-2.0.html +[43]: https://maven.apache.org/plugins/maven-assembly-plugin/ +[44]: https://maven.apache.org/plugins/maven-jar-plugin/ +[45]: https://github.com/exasol/artifact-reference-checker-maven-plugin +[46]: https://maven.apache.org/plugins/maven-deploy-plugin/ +[47]: https://maven.apache.org/plugins/maven-gpg-plugin/ +[48]: https://maven.apache.org/plugins/maven-source-plugin/ +[49]: https://maven.apache.org/plugins/maven-javadoc-plugin/ +[50]: http://www.sonatype.com/public-parent/nexus-maven-plugins/nexus-staging/nexus-staging-maven-plugin/ +[51]: http://www.eclipse.org/legal/epl-v10.html +[52]: https://maven.apache.org/plugins/maven-dependency-plugin/ +[53]: https://maven.apache.org/surefire/maven-failsafe-plugin/ +[54]: https://www.jacoco.org/jacoco/trunk/doc/maven.html +[55]: https://github.com/exasol/error-code-crawler-maven-plugin/ +[56]: https://github.com/exasol/error-code-crawler-maven-plugin/blob/main/LICENSE +[57]: http://zlika.github.io/reproducible-build-maven-plugin diff --git a/doc/changes/changelog.md b/doc/changes/changelog.md index d8b1f12..7f777b4 100644 --- a/doc/changes/changelog.md +++ b/doc/changes/changelog.md @@ -1,5 +1,6 @@ # Changes +* [8.0.0](changes_8.0.0.md) * [7.2.0](changes_7.2.0.md) * [7.1.6](changes_7.1.6.md) * [7.1.5](changes_7.1.5.md) diff --git a/doc/changes/changes_8.0.0.md b/doc/changes/changes_8.0.0.md new file mode 100644 index 0000000..52aff5d --- /dev/null +++ b/doc/changes/changes_8.0.0.md @@ -0,0 +1,40 @@ +# Exasol Virtual Schema 8.0.0, released 2024-04-02 + +Code name: Charset is always `utf-8`, deprecated IMPORT_DATA_TYPES `FROM_RESULT_SET` value + +## Summary + +The behaviour when it comes to character sets is now simplified, +The target charset is now always UTF-8. + +The `IMPORT_DATA_TYPES` property (and value `FROM_RESULT_SET`) are now deprecated (change in vs-common-jdbc): +An exception will be thrown when users use`FROM_RESULT_SET`. The exception message warns the user that the value is no longer supported and the property itself is also deprecated. + +Using timestamps with local timezone in the Exasol virtual schema now returns a proper timestamp with local timezone. + +Querying char and varchar datatypes in LOCAL mode are now returned with UTF8 characterset, as expected. + +## Refactoring + +* #105: Updated tests to include Exasol V8/ Update to vsjdbc 12.0.0 + +## Dependency Updates + +### Compile Dependency Updates + +* Updated `com.exasol:virtual-schema-common-jdbc:11.0.2` to `12.0.0` + +### Test Dependency Updates + +* Added `com.exasol:udf-debugging-java:0.6.11` +* Updated `com.exasol:virtual-schema-common-jdbc:11.0.2` to `12.0.0` + +### Plugin Dependency Updates + +* Updated `com.exasol:error-code-crawler-maven-plugin:1.3.1` to `2.0.1` +* Updated `com.exasol:project-keeper-maven-plugin:3.0.1` to `4.2.0` +* Updated `org.apache.maven.plugins:maven-compiler-plugin:3.11.0` to `3.12.1` +* Updated `org.apache.maven.plugins:maven-failsafe-plugin:3.2.3` to `3.2.5` +* Updated `org.apache.maven.plugins:maven-javadoc-plugin:3.4.1` to `3.6.3` +* Updated `org.apache.maven.plugins:maven-surefire-plugin:3.2.3` to `3.2.5` +* Updated `org.codehaus.mojo:flatten-maven-plugin:1.5.0` to `1.6.0` diff --git a/doc/dialects/exasol.md b/doc/dialects/exasol.md index 370ed55..dd58183 100644 --- a/doc/dialects/exasol.md +++ b/doc/dialects/exasol.md @@ -17,7 +17,7 @@ The SQL statement below creates the adapter script, defines the Java class that ```sql CREATE JAVA ADAPTER SCRIPT SCHEMA_FOR_VS_SCRIPT.ADAPTER_SCRIPT_EXASOL AS %scriptclass com.exasol.adapter.RequestDispatcher; - %jar /buckets///virtual-schema-dist-11.0.2-exasol-7.2.0.jar; + %jar /buckets///virtual-schema-dist-12.0.0-exasol-8.0.0.jar; / ``` @@ -114,6 +114,14 @@ Pushdown query with `GENERATE_JDBC_DATATYPE_MAPPING_FOR_EXA = 'true'`: IMPORT INTO (c1 DECIMAL(36,1), c2 .... ) FROM EXA AT "EXA_CONNECTION" STATEMENT '...' ``` +##### Data type mismatch + +In case you run into a `Data type mismatch` issue which looks like this: +`Adapter generated invalid pushdown query for virtual table : Data type mismatch in column number (1-indexed).Expected , but got .` + +You can set the datatype mapping to true: `GENERATE_JDBC_DATATYPE_MAPPING_FOR_EXA = 'true'`. +This will usually solve the issue by providing type hints. + ### Using `IMPORT FROM JDBC` You can alternatively use a regular JDBC connection for the `IMPORT`. Note that this option is slower because it lacks the parallelization the `IMPORT FROM EXA` variant. @@ -204,7 +212,7 @@ The Exasol SQL dialect supports all capabilities that are supported by the virtu ### Data type `TIMESTAMP WITH LOCAL TIME ZONE` -Using literals and constant expressions with `TIMESTAMP WITH LOCAL TIME ZONE` data type in Virtual Schemas can produce an incorrect results. +Using literals and constant expressions with `TIMESTAMP WITH LOCAL TIME ZONE` data type in Virtual Schemas can produce incorrect results. * We recommend using `TIMESTAMP` instead. * If you are willing to take the risk and want to use `TIMESTAMP WITH LOCAL TIME ZONE` anyway, please, create a Virtual Schema with the following additional property `IGNORE_ERRORS = 'TIMESTAMP_WITH_LOCAL_TIME_ZONE_USAGE'`. * We also recommend to set Exasol system `time_zone` to UTC while working with `TIMESTAMP WITH LOCAL TIME ZONE`. diff --git a/pk_generated_parent.pom b/pk_generated_parent.pom index be8777a..d215b61 100644 --- a/pk_generated_parent.pom +++ b/pk_generated_parent.pom @@ -3,7 +3,7 @@ 4.0.0 com.exasol exasol-virtual-schema-generated-parent - 7.2.0 + 8.0.0 pom UTF-8 @@ -82,7 +82,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 ${java.version} ${java.version} @@ -120,7 +120,7 @@ org.codehaus.mojo flatten-maven-plugin - 1.5.0 + 1.6.0 true oss @@ -159,7 +159,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.3 + 3.2.5 @@ -183,6 +183,17 @@ file:///${project.basedir}/versionsMavenPluginRules.xml + false + true + true + true + false + true + true + true + false + true + true @@ -323,6 +334,7 @@ true true true + ${java.version} @@ -369,7 +381,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.2.3 + 3.2.5 -Djava.util.logging.config.file=src/test/resources/logging.properties ${argLine} @@ -438,7 +450,7 @@ com.exasol error-code-crawler-maven-plugin - 1.3.1 + 2.0.1 verify diff --git a/pom.xml b/pom.xml index d9dea63..abb79ab 100644 --- a/pom.xml +++ b/pom.xml @@ -2,12 +2,12 @@ 4.0.0 exasol-virtual-schema - 7.2.0 + 8.0.0 Exasol Virtual Schema This projects contains the Exasol dialect for Exasol's Virtual Schema https://github.com/exasol/exasol-virtual-schema/ - 11.0.2 + 12.0.0 @@ -89,13 +89,19 @@ 1.2.0 test + + com.exasol + udf-debugging-java + 0.6.11 + test + com.exasol project-keeper-maven-plugin - 3.0.1 + 4.2.0 @@ -160,13 +166,13 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + true - + @@ -175,7 +181,7 @@ exasol-virtual-schema-generated-parent com.exasol - 7.2.0 + 8.0.0 pk_generated_parent.pom diff --git a/src/main/java/com/exasol/adapter/dialects/exasol/ExasolLocalQueryRewriter.java b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolLocalQueryRewriter.java index 08cf169..85a55ef 100644 --- a/src/main/java/com/exasol/adapter/dialects/exasol/ExasolLocalQueryRewriter.java +++ b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolLocalQueryRewriter.java @@ -37,7 +37,7 @@ class ExasolLocalQueryRewriter implements QueryRewriter { public String rewrite(final SqlStatement statement, final List selectListDataTypes, final ExaMetadata exaMetadata, final AdapterProperties properties) throws AdapterException { final SqlGenerationContext context = new SqlGenerationContext(properties.getCatalogName(), - properties.getSchemaName(), false); + properties.getSchemaName(), true); final SqlGenerator sqlGeneratorVisitor = this.dialect.getSqlGenerator(context); final String selectStatement = sqlGeneratorVisitor.generateSqlFor(statement); LOGGER.finer(() -> "SELECT push-down statement:\n" + selectStatement); diff --git a/src/main/java/com/exasol/adapter/dialects/exasol/ExasolLocalSqlGenerationVisitor.java b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolLocalSqlGenerationVisitor.java new file mode 100644 index 0000000..0788471 --- /dev/null +++ b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolLocalSqlGenerationVisitor.java @@ -0,0 +1,59 @@ +package com.exasol.adapter.dialects.exasol; + +import com.exasol.adapter.AdapterException; +import com.exasol.adapter.dialects.SqlDialect; +import com.exasol.adapter.dialects.rewriting.SqlGenerationContext; +import com.exasol.adapter.metadata.DataType; +import com.exasol.adapter.metadata.DataType.ExaDataType; +import com.exasol.adapter.sql.SqlColumn; + +/** + * This class generates SQL queries for the {@link ExasolSqlDialect}. It is a 'specialisation' for LOCAL mode, based on + * {@link ExasolSqlGenerationVisitor}. It adds a cast to UTF8 for char and varchar datatype imports. + */ +public class ExasolLocalSqlGenerationVisitor extends ExasolSqlGenerationVisitor { + /** + * Creates a new instance of the {@link ExasolLocalSqlGenerationVisitor}. + * + * @param dialect {@link ExasolSqlDialect} dialect + * @param context SQL generation context + */ + ExasolLocalSqlGenerationVisitor(final SqlDialect dialect, final SqlGenerationContext context) { + super(dialect, context); + } + + @Override + public String visit(final SqlColumn column) throws AdapterException { + final ExasolSqlDialect exasolSqlDialect = new ExasolSqlDialect(null, null); + final String tablePrefix = getTablePrefix(column, exasolSqlDialect); + final ExaDataType exaDataType = column.getMetadata().getType().getExaDataType(); + if (exaDataType == DataType.ExaDataType.CHAR || // + exaDataType == DataType.ExaDataType.VARCHAR) { + // Provide a cast to corresponding datatype with the same length but with utf8 as charset. + return addCastAndReturnColumnName(exaDataType, column, exasolSqlDialect, tablePrefix); + } else { + return tablePrefix + exasolSqlDialect.applyQuote(column.getName()); + } + } + + private String addCastAndReturnColumnName(final ExaDataType exaDataType, final SqlColumn column, + final ExasolSqlDialect exasolSqlDialect, final String tablePrefix) { + final int size = column.getMetadata().getType().getSize(); + + final String dataTypeStr = exaDataType == DataType.ExaDataType.CHAR ? "CHAR" : "VARCHAR"; + return "CAST(" + tablePrefix + exasolSqlDialect.applyQuote(column.getName()) + " AS " + dataTypeStr + "(" + size + + ") UTF8)"; + } + + private String getTablePrefix(final SqlColumn column, final ExasolSqlDialect exasolSqlDialect) { + String tablePrefix = ""; + if (column.hasTableAlias()) { + tablePrefix = exasolSqlDialect.applyQuote(column.getTableAlias()) + + exasolSqlDialect.getTableCatalogAndSchemaSeparator(); + } else if ((column.getTableName() != null) && !column.getTableName().isEmpty()) { + tablePrefix = exasolSqlDialect.applyQuote(column.getTableName()) + + exasolSqlDialect.getTableCatalogAndSchemaSeparator(); + } + return tablePrefix; + } +} diff --git a/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialect.java b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialect.java index 8ebd0a9..78592d5 100644 --- a/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialect.java +++ b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialect.java @@ -155,7 +155,12 @@ public String getStringLiteral(final String value) { @Override public SqlGenerator getSqlGenerator(final SqlGenerationContext context) { - return new ExasolSqlGenerationVisitor(this, context); + if (context.isLocal()){ + return new ExasolLocalSqlGenerationVisitor(this, context); + } else { + return new ExasolSqlGenerationVisitor(this, context); + } + } /** diff --git a/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlGenerationVisitor.java b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlGenerationVisitor.java index 7722dd6..4edfdab 100644 --- a/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlGenerationVisitor.java +++ b/src/main/java/com/exasol/adapter/dialects/exasol/ExasolSqlGenerationVisitor.java @@ -32,7 +32,8 @@ public String visit(final SqlLiteralTimestampUtc literal) { final ExasolSqlDialect exasolSqlDialect = (ExasolSqlDialect) getDialect(); if (exasolSqlDialect.isTimestampWithLocalTimeZoneEnabled()) { LOGGER.info("IGNORE_ERRORS = '" + EXASOL_TIMESTAMP_WITH_LOCAL_TIME_ZONE_SWITCH + "' property is enabled."); - return super.visit(literal); + + return "cast(TIMESTAMP " + getDialect().getStringLiteral(literal.getValue()) + " as timestamp with local time zone)"; } else { throw new UnsupportedOperationException(ExaError.messageBuilder("E-VSEXA-5") // .message("Attention! Using literals and constant expressions with datatype " diff --git a/src/test/java/com/exasol/adapter/dialects/exasol/AbstractExasolSqlDialectIT.java b/src/test/java/com/exasol/adapter/dialects/exasol/AbstractExasolSqlDialectIT.java index 2b19a0c..9ffafd9 100644 --- a/src/test/java/com/exasol/adapter/dialects/exasol/AbstractExasolSqlDialectIT.java +++ b/src/test/java/com/exasol/adapter/dialects/exasol/AbstractExasolSqlDialectIT.java @@ -5,12 +5,11 @@ import static com.exasol.adapter.dialects.exasol.IntegrationTestConfiguration.VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION; import static com.exasol.dbbuilder.dialects.exasol.ExasolObjectPrivilege.SELECT; import static com.exasol.matcher.ResultSetStructureMatcher.table; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.matchesPattern; import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.FileNotFoundException; import java.math.BigDecimal; @@ -26,7 +25,6 @@ import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.ValueSource; import org.opentest4j.AssertionFailedError; -import org.testcontainers.containers.JdbcDatabaseContainer.NoDriverFoundException; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -39,6 +37,8 @@ import com.exasol.dbbuilder.dialects.exasol.AdapterScript.Language; import com.exasol.matcher.ResultSetStructureMatcher.Builder; import com.exasol.matcher.TypeMatchMode; +import com.exasol.udfdebugging.UdfTestSetup; +import com.github.dockerjava.api.model.ContainerNetwork; @Tag("integration") @Testcontainers @@ -60,12 +60,27 @@ abstract class AbstractExasolSqlDialectIT { private final Set expectVarcharFor = expectVarcharFor(); @BeforeAll - static void beforeAll() throws BucketAccessException, TimeoutException, NoDriverFoundException, SQLException, - FileNotFoundException { - connection = EXASOL.createConnection(""); - objectFactory = new ExasolObjectFactory(connection); - adapterSchema = objectFactory.createSchema("ADAPTER_SCHEMA"); - adapterScript = installVirtualSchemaAdapter(adapterSchema); + static void beforeAll() { + try { + connection = EXASOL.createConnection(""); + final UdfTestSetup udfTestSetup = new UdfTestSetup(getTestHostIpFromInsideExasol(), + EXASOL.getDefaultBucket(), connection); + objectFactory = new ExasolObjectFactory(connection, + ExasolObjectConfiguration.builder().withJvmOptions(udfTestSetup.getJvmOptions()).build()); + adapterSchema = objectFactory.createSchema("ADAPTER_SCHEMA"); + adapterScript = installVirtualSchemaAdapter(adapterSchema); + + } catch (final SQLException | BucketAccessException | TimeoutException | FileNotFoundException exception) { + throw new IllegalStateException("Failed to created test setup.", exception); + } + } + + private static String getTestHostIpFromInsideExasol() { + final Map networks = EXASOL.getContainerInfo().getNetworkSettings().getNetworks(); + if (networks.size() == 0) { + return null; + } + return networks.values().iterator().next().getGateway(); } private static AdapterScript installVirtualSchemaAdapter(final ExasolSchema adapterSchema) @@ -187,7 +202,7 @@ private ResultSet selectAllFrom(final String tableName) throws SQLException { return query("SELECT * FROM " + tableName); } - private String getVirtualTableName(final VirtualSchema virtualSchema, final Table table) { + protected String getVirtualTableName(final VirtualSchema virtualSchema, final Table table) { return virtualSchema.getFullyQualifiedName() + ".\"" + table.getName() + "\""; } @@ -358,7 +373,7 @@ void testIdentifierCaseSensitivityOnTable() { } } - private void assertVsQuery(final String sql, final Matcher expected) { + protected void assertVsQuery(final String sql, final Matcher expected) { try { assertThat(query(sql), expected); } catch (final SQLException exception) { @@ -848,8 +863,27 @@ void testCurrentClusterFunction() throws SQLException { } } + static void assumeExasol8OrHigher() { + assumeTrue(isExasol8OrHigher(), "is Exasol version 8 or higher"); + } + + static void assumeExasol7OrLower() { + assumeTrue(isExasol7OrLower(), "is Exasol version 7 or lower"); + } + + static boolean isExasol8OrHigher() { + final ExasolDockerImageReference imageReference = EXASOL.getDockerImageReference(); + return imageReference.hasMajor() && (imageReference.getMajor() >= 8); + } + + static boolean isExasol7OrLower() { + final ExasolDockerImageReference imageReference = EXASOL.getDockerImageReference(); + return imageReference.hasMajor() && (imageReference.getMajor() <= 7); + } + @Test void testWildcards() throws SQLException { + assumeExasol7OrLower(); final String nameWithWildcard = "A_A"; this.sourceSchema.createTable(nameWithWildcard, "A", "VARCHAR(20)"); this.sourceSchema.createTable("AXA", "X", "VARCHAR(20)"); @@ -858,6 +892,17 @@ void testWildcards() throws SQLException { table().row("A", "VARCHAR(20) UTF8", null, null, null).matches()); } + @Test + void testWildcardsExasolV8() throws SQLException { + assumeExasol8OrHigher(); + final String nameWithWildcard = "A_A"; + this.sourceSchema.createTable(nameWithWildcard, "A", "VARCHAR(20)"); + this.sourceSchema.createTable("AXA", "X", "VARCHAR(20)"); + this.virtualSchema = createVirtualSchema(this.sourceSchema); + assertVsQuery("describe " + this.virtualSchema.getFullyQualifiedName() + ".\"" + nameWithWildcard + "\"", + table().row("A", "VARCHAR(20) UTF8", null, null, null, null).matches()); + } + @Test @DisplayName("Verify DISTINCT with integer literal") void testDistinctWithIntegerLiteral() throws SQLException { diff --git a/src/test/java/com/exasol/adapter/dialects/exasol/ExasolColumnMetadataReaderTest.java b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolColumnMetadataReaderTest.java index 287dfa6..dfa843f 100644 --- a/src/test/java/com/exasol/adapter/dialects/exasol/ExasolColumnMetadataReaderTest.java +++ b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolColumnMetadataReaderTest.java @@ -104,7 +104,7 @@ void testMapJdbcTypeVarchar() { @Test void testMapJdbcTypeVarcharAscii() { - assertTypeMapped(varchar(5).byteSize(5), DataType.createVarChar(5, ExaCharset.ASCII)); + assertTypeMapped(varchar(5).byteSize(5), DataType.createVarChar(5, ExaCharset.UTF8)); } @Test @@ -124,7 +124,7 @@ void testMapJdbcTypeCharUtf8() { @Test void testMapJdbcTypeCharAscii() { - assertTypeMapped(charType(5).byteSize(5), DataType.createChar(5, ExaCharset.ASCII)); + assertTypeMapped(charType(5).byteSize(5), DataType.createChar(5, ExaCharset.UTF8)); } @Test diff --git a/src/test/java/com/exasol/adapter/dialects/exasol/ExasolLocalSqlGenerationVisitorTest.java b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolLocalSqlGenerationVisitorTest.java new file mode 100644 index 0000000..1995512 --- /dev/null +++ b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolLocalSqlGenerationVisitorTest.java @@ -0,0 +1,67 @@ +package com.exasol.adapter.dialects.exasol; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import com.exasol.adapter.AdapterException; +import com.exasol.adapter.AdapterProperties; +import com.exasol.adapter.dialects.SqlDialect; +import com.exasol.adapter.dialects.dummy.DummySqlDialect; +import com.exasol.adapter.dialects.rewriting.SqlGenerationContext; +import com.exasol.adapter.metadata.ColumnMetadata; +import com.exasol.adapter.metadata.DataType; +import com.exasol.adapter.metadata.DataType.ExaCharset; +import com.exasol.adapter.sql.SqlColumn; + +public class ExasolLocalSqlGenerationVisitorTest { + private static ExasolLocalSqlGenerationVisitor exasolLocalSqlGenerationVisitor; + + @BeforeAll + public static void beforeAll() { + final Map rawProperties = new HashMap<>(); + final AdapterProperties adapterProperties = new AdapterProperties(rawProperties); + final SqlDialect sqlDialect = new DummySqlDialect(null, adapterProperties); + final SqlGenerationContext context = new SqlGenerationContext("", "TEXT_SCHEMA_NAME", false); + exasolLocalSqlGenerationVisitor = new ExasolLocalSqlGenerationVisitor(sqlDialect, context); + } + + @Test + void testVisitSqlLiteralVarchar() throws AdapterException { + + final SqlColumn argument = new SqlColumn(1, // + ColumnMetadata.builder().name("a").type(DataType.createVarChar(20, ExaCharset.ASCII)).build(), + "table_name"); // + + assertThat(exasolLocalSqlGenerationVisitor.visit(argument), + equalTo("CAST(\"table_name\".\"a\" AS VARCHAR(20) UTF8)")); + + } + + @Test + void testVisitSqlLiteralChar() throws AdapterException { + + final SqlColumn argument = new SqlColumn(1, // + ColumnMetadata.builder().name("a").type(DataType.createChar(20, ExaCharset.ASCII)).build(), + "table_name"); // + + assertThat(exasolLocalSqlGenerationVisitor.visit(argument), + equalTo("CAST(\"table_name\".\"a\" AS CHAR(20) UTF8)")); + + } + + @Test + void testVisitSqlLiteralDouble() throws AdapterException { + + final SqlColumn argument = new SqlColumn(1, // + ColumnMetadata.builder().name("a").type(DataType.createDouble()).build(), "table_name"); // + + assertThat(exasolLocalSqlGenerationVisitor.visit(argument), equalTo("\"table_name\".\"a\"")); + + } +} diff --git a/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialectExaConnectionIT.java b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialectExaConnectionIT.java index 25ba89b..ed24ac2 100644 --- a/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialectExaConnectionIT.java +++ b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlDialectExaConnectionIT.java @@ -34,6 +34,7 @@ *
  • {@code GEOMETRY} types are reported with JDBC type name {@code VARCHAR} in ResultSets
  • *
      */ + class ExasolSqlDialectExaConnectionIT extends AbstractRemoteExasolVirtualSchemaConnectionIT { private static final String EXA_CONNECTION_NAME = "EXA_CONNECTION"; private ConnectionDefinition exaConnection; @@ -69,8 +70,19 @@ protected Map getConnectionSpecificVirtualSchemaProperties() { return Map.of("IMPORT_FROM_EXA", "true", EXASOL_CONNECTION_PROPERTY, this.exaConnection.getName()); } + // These tests were overridden for the following reasons: + // Strict datatype checking which is by default enabled for Exasol V8 makes a number of these tests fail. + // + // The old tests that work for DB versions prior to strict datatype checking + // thus can only be run for earlier Exasol DB versions and have to be skipped for V8. + // + // The tests using the newer GENERATE_JDBC_DATATYPE_MAPPING_FOR_EXA switch that fixes most of the issues with strict + // datatype checking on the pushed down queries + // can be found in ExasolSqlDialectExaConnectionWithDataTypesIT. + @Test void testPasswordNotVisibleInImportFromExa() throws NoDriverFoundException, SQLException { + assumeExasol7OrLower(); final Table table = this.sourceSchema.createTable("T1", "C1", "VARCHAR(20)").insert("Hello."); this.virtualSchema = createVirtualSchema(this.sourceSchema); final String sql = "SELECT * FROM " + this.virtualSchema.getFullyQualifiedName() + ".\"" + table.getName() @@ -106,6 +118,7 @@ private ResultSet explainVirtual(final String sql) throws SQLException { @Override @Test void testCharMappingAscii() { + assumeExasol7OrLower(); final Table table = createSingleColumnTable("CHAR(20) ASCII").insert("sun").insert("rain"); assertVirtualTableContents(table, table("VARCHAR").row(pad("sun", 20)).row(pad("rain", 20)).matches()); } @@ -113,12 +126,14 @@ void testCharMappingAscii() { @Override @Test void testCharMappingUtf8() { + assumeExasol7OrLower(); verifyCharMappingUtf8("VARCHAR"); } @Override @Test void testCastVarcharToChar() { + assumeExasol7OrLower(); castFrom("VARCHAR(20)").to("CHAR(40)").input("Hello.").accept("VARCHAR").verify(pad("Hello.", 40)); } @@ -133,4 +148,209 @@ void joinHashtypeTables() { containsString( "Adapter generated invalid pushdown query for virtual table VIRTUAL: Data type mismatch in column number 1 (1-indexed).Expected HASHTYPE(16 BYTE), but got VARCHAR(32) UTF8."))); } + + @Test + @Override + void testNonDefaultGeometry() { + assumeExasol7OrLower(); + typeAssertionFor("GEOMETRY(4321)").withValue("POINT (2 5)") // + .expectTypeOf("GEOMETRY(4321)") // + .expectDescribeType("GEOMETRY(4321)") // + .expectResultSetType(expectDataType("GEOMETRY")) // + .runAssert(); + + } + + @Override + @Test + void testHashTypeWithBitSize() { + assumeExasol7OrLower(); + typeAssertionFor("HASHTYPE(16 BIT)").withValue("550e") // + .expectDescribeType("HASHTYPE(2 BYTE)") // + .expectTypeOf("HASHTYPE(2 BYTE)") // + .expectResultSetType(expectDataType("HASHTYPE")) // + .runAssert(); + } + + @Override + @Test + void testDefaultIntervalYearToMonth() { + assumeExasol7OrLower(); + typeAssertionFor("INTERVAL YEAR TO MONTH").withValue("5-3") // + .expectTypeOf("INTERVAL YEAR(2) TO MONTH") // + .expectDescribeType("INTERVAL YEAR(2) TO MONTH") // + .expectResultSetType(expectDataType("INTERVAL YEAR TO MONTH")) // + .expectValue("+05-03") // + .runAssert(); + } + + @Override + @Test + void testDefaultGeometry() { + assumeExasol7OrLower(); + typeAssertionFor("GEOMETRY").withValue("POINT (2 5)") // + .expectTypeOf("GEOMETRY") // + .expectDescribeType("GEOMETRY") // + .expectResultSetType(expectDataType("GEOMETRY")) // + .runAssert(); + } + + @Override + @Test + void testDefaultIntervalDayToSecond() { + assumeExasol7OrLower(); + typeAssertionFor("INTERVAL DAY TO SECOND").withValue("2 12:50:10.123") // + // day: 2 digits, seconds: 3 digits after decimal point + .expectTypeOf("INTERVAL DAY(2) TO SECOND(3)") // + .expectDescribeType("INTERVAL DAY(2) TO SECOND(3)") // + .expectResultSetType(expectDataType("INTERVAL DAY TO SECOND")) // + .expectValue("+02 12:50:10.123") // + .runAssert(); + } + + @Override + @Test + void testGeometryMapping() { + assumeExasol7OrLower(); + // Note that the JDBC driver reports the result as VARCHAR for Exasol database with major version < 8 + final Table table = createSingleColumnTable("GEOMETRY").insert("POINT (2 3)"); + assertVirtualTableContents(table, table(expectDataType("GEOMETRY")).row("POINT (2 3)").matches()); + } + + @Override + @Test + void testNonDefaultIntervalYearToMonth() { + assumeExasol7OrLower(); + typeAssertionFor("INTERVAL YEAR(4) TO MONTH") // 4 digits for year + .withValue("5-3") // sample interval of 5 years and 3 months + .expectTypeOf("INTERVAL YEAR(4) TO MONTH") // + .expectDescribeType("INTERVAL YEAR(4) TO MONTH") // + .expectResultSetType(expectDataType("INTERVAL YEAR TO MONTH")) // + .expectValue("+0005-03") // 4 digits for year + .runAssert(); + } + + @Override + @Test + void testNonDefaultIntervalDayToSecond() { + assumeExasol7OrLower(); + // day: 4 digits, seconds: 6 digits after decimal point + typeAssertionFor("INTERVAL DAY(4) TO SECOND(6)").withValue("2 12:50:10.123") // + .expectTypeOf("INTERVAL DAY(4) TO SECOND(6)") // + .expectDescribeType("INTERVAL DAY(4) TO SECOND(6)") // + .expectResultSetType(expectDataType("INTERVAL DAY TO SECOND")) // + .expectValue("+0002 12:50:10.123000") // + .runAssert(); + } + + @Override + @Test + void testNonDefaultHashType() { + assumeExasol7OrLower(); + typeAssertionFor("HASHTYPE(4 BYTE)").withValue("550e8400") // + .expectDescribeType("HASHTYPE(4 BYTE)") // + .expectTypeOf("HASHTYPE(4 BYTE)") // + .expectResultSetType(expectDataType("HASHTYPE")) // + .runAssert(); + } + + @Override + @Test + void testCastVarcharAsGeometry() { + assumeExasol7OrLower(); + castFrom("VARCHAR(20)").to("GEOMETRY(5)").input("POINT(2 5)").accept(expectDataType("GEOMETRY")) + .verify("POINT (2 5)"); + } + + @Override + @Test + void testDefaultHashType() { + assumeExasol7OrLower(); + typeAssertionFor("HASHTYPE").withValue("550e8400-e29b-11d4-a716-446655440000") + .expectDescribeType("HASHTYPE(16 BYTE)") // + .expectTypeOf("HASHTYPE(16 BYTE)") // + .expectResultSetType(expectDataType("HASHTYPE")) // + .expectValue("550e8400e29b11d4a716446655440000") // + .runAssert(); + } + + @Override + @Test + void testIntervalYearToMonthMapping() { + assumeExasol7OrLower(); + final Table table = createSingleColumnTable("INTERVAL YEAR (9) TO MONTH")// + .insert("-999999999-11") // + .insert("-1-1") // + .insert("0-0") // + .insert("1-1") // + .insert("999999999-11"); + // why is precision 9 missing in expected data type? + assertVirtualTableContents(table, table(expectDataType("INTERVAL YEAR TO MONTH")) // + .row("-999999999-11") // + .row("-000000001-01") // + .row("+000000000-00") // + .row("+000000001-01") // + .row("+999999999-11") // + .matches()); + } + + @Override + @Test + void testIntervalDayToSecondMapping() { + assumeExasol7OrLower(); + final Table table = createSingleColumnTable("INTERVAL DAY (9) TO SECOND") // + .insert("-999999999 23:59:59.999") // + .insert("-1 12:34:56.789") // + .insert("0 00:00:00.000") // + .insert("1 12:34:56.789") // + .insert("999999999 23:59:59.999"); + // why is precision 9 missing in expected data type? + assertVirtualTableContents(table, table(expectDataType("INTERVAL DAY TO SECOND")) // + .row("-999999999 23:59:59.999") // + .row("-000000001 12:34:56.789") // + .row("+000000000 00:00:00.000") // + .row("+000000001 12:34:56.789") // + .row("+999999999 23:59:59.999") // + .matches()); + } + + @Override + @Test + void testCastVarcharAsIntervalDayToSecond() { + assumeExasol7OrLower(); + // why is precision 5 and 2 missing in expected data type? + castFrom("VARCHAR(30)").to("INTERVAL DAY (5) TO SECOND (2)").input("+00003 12:50:10.12") + .accept(expectDataType("INTERVAL DAY TO SECOND")).verify("+00003 12:50:10.12"); + } + + @Override + @Test + void testCastVarcharAsIntervalYearToMonth() { + assumeExasol7OrLower(); + // why is precision 5 missing in expectedDataType? + castFrom("VARCHAR(30)").to("INTERVAL YEAR (5) TO MONTH").input("+00004-06") + .accept(expectDataType("INTERVAL YEAR TO MONTH")).verify("+00004-06"); + } + + @Override + @Test + void testCaseEqual() { + assumeExasol7OrLower(); + final Table table = createSingleColumnTable("INTEGER").insert(1).insert(2).insert(3); + this.virtualSchema = createVirtualSchema(this.sourceSchema); + assertVsQuery("SELECT CASE C1 WHEN 1 THEN 'YES' WHEN 2 THEN 'PERHAPS' ELSE 'NO' END FROM " // + + getVirtualTableName(this.virtualSchema, table), // + table().row("YES").row("PERHAPS").row("NO").matches()); + } + + @Override + @Test + void testCaseGreaterThan() { + assumeExasol7OrLower(); + final Table table = createSingleColumnTable("INTEGER").insert(1).insert(2).insert(3); + this.virtualSchema = createVirtualSchema(this.sourceSchema); + assertVsQuery("SELECT CASE WHEN C1 > 1 THEN 'YES' ELSE 'NO' END FROM " // + + getVirtualTableName(this.virtualSchema, table), // + table().row("NO").row("YES").row("YES").matches()); + } } diff --git a/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlGenerationVisitorTest.java b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlGenerationVisitorTest.java index 583f56d..4195578 100644 --- a/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlGenerationVisitorTest.java +++ b/src/test/java/com/exasol/adapter/dialects/exasol/ExasolSqlGenerationVisitorTest.java @@ -39,7 +39,7 @@ void testVisitSqlLiteralTimestampUtc() { this.exasolSqlDialect, null); final SqlLiteralTimestampUtc sqlLiteralTimestampUtc = new SqlLiteralTimestampUtc(value); assertThat(exasolSqlGenerationVisitor.visit(sqlLiteralTimestampUtc), - equalTo("TIMESTAMP '2015-12-01 12:01:01.1234'")); + equalTo("cast(TIMESTAMP '2015-12-01 12:01:01.1234' as timestamp with local time zone)")); } @Test diff --git a/src/test/java/com/exasol/adapter/dialects/exasol/IntegrationTestConfiguration.java b/src/test/java/com/exasol/adapter/dialects/exasol/IntegrationTestConfiguration.java index 2ad3e52..993f2cb 100644 --- a/src/test/java/com/exasol/adapter/dialects/exasol/IntegrationTestConfiguration.java +++ b/src/test/java/com/exasol/adapter/dialects/exasol/IntegrationTestConfiguration.java @@ -3,12 +3,12 @@ import java.nio.file.Path; public final class IntegrationTestConfiguration { - private static final String DEFAULT_DOCKER_DB_REFERENCE = "7.1.25"; + private static final String DEFAULT_DOCKER_DB_REFERENCE = "8.24.0"; /** * Do not use MavenProjectVersionGetter here to enable reference checker to check if reference points to the latest * version. */ - public static final String VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION = "virtual-schema-dist-11.0.2-exasol-7.2.0.jar"; + public static final String VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION = "virtual-schema-dist-12.0.0-exasol-8.0.0.jar"; public static final Path PATH_TO_VIRTUAL_SCHEMAS_JAR = Path.of("target", VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION); private IntegrationTestConfiguration() {