Skip to content

[Bug] [chunjun-connection-jdbc-base] configure ”customSql“ in postgresql db  #1370

@kinoxyz1

Description

@kinoxyz1

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

In the postgresql database, use the customSql parameter to specify the query statement, which cannot be executed。

com.dtstack.chunjun.connector.jdbc.util.JdbcUtil:169

querySql = String.format("select * from ((%s) custom) where 1=2", querySql);

When the database is postgresql, the sql spliced in this way is wrong syntax。

What you expected to happen

This is a bad syntax: select * from ((%s) custom) where 1=2

How to reproduce

{
    "job": {
      "content": [
        {
          "reader": {
            "name": "postgresqlreader",
            "parameter": {
              "column": [
                {
                  "name": "val_character_varying",
                  "type": "character_varying"
                },
                {
                    "name": "val_varchar",
                    "type": "varchar"
                },
                {
                    "name": "val_character",
                    "type": "character"
                },
                {
                    "name": "val_char",
                    "type": "char"
                },
                {
                    "name": "val_text",
                    "type": "text"
                },
                {
                    "name": "val_name",
                    "type": "name"
                },
                {
                    "name": "val_bytea",
                    "type": "bytea"
                },
                {
                    "name": "val_timestamp",
                    "type": "timestamp"
                },
                {
                    "name": "val_timestamptz",
                    "type": "timestamp"
                },
                {
                    "name": "val_date",
                    "type": "date"
                },
                {
                    "name": "val_time",
                    "type": "time"
                },
                {
                    "name": "val_timetz",
                    "type": "time"
                },
                {
                    "name": "val_boolean",
                    "type": "boolean"
                }
              ],
              "username": "postgres",
              "password": "root",
              "customSql": "select * from customtable where id < 100",
              "connection": [
                {
                  "jdbcUrl": [
                    "jdbc:postgresql://localhost:5432/dev?useSSL=false"
                  ],
                  "table": [
                    "dim_without_numeric"
                  ]
                }
              ]
            }
          },
          "writer": {
            "name": "postgresqlwriter",
            "parameter": {
              "username": "postgres",
              "password": "root",
              "connection": [
                {
                  "jdbcUrl": "jdbc:postgresql://localhost:5432/dev?useSSL=false",
                  "table": [
                    "dim_without_numeric"
                  ]
                }
              ],
              "writeMode": "insert",
              "column": [
                {
                    "name": "val_character_varying",
                    "type": "character_varying"
                  },
                  {
                      "name": "val_varchar",
                      "type": "varchar"
                  },
                  {
                      "name": "val_character",
                      "type": "character"
                  },
                  {
                      "name": "val_char",
                      "type": "char"
                  },
                  {
                      "name": "val_text",
                      "type": "text"
                  },
                  {
                      "name": "val_name",
                      "type": "name"
                  },
                  {
                      "name": "val_bytea",
                      "type": "bytea"
                  },
                  {
                      "name": "val_timestamp",
                      "type": "timestamp"
                  },
                  {
                      "name": "val_timestamptz",
                      "type": "timestamptz"
                  },
                  {
                      "name": "val_date",
                      "type": "date"
                  },
                  {
                      "name": "val_time",
                      "type": "time"
                  },
                  {
                      "name": "val_timetz",
                      "type": "timetz"
                  },
                  {
                      "name": "val_boolean",
                      "type": "boolean"
                  }
              ]
            }
          }
        }
      ],
      "setting": {
        "speed": {
          "channel": 1,
          "bytes": 0
        }
      }
    }
  }

Anything else

No response

Version

master

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions