Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Sql JobType added #292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

aycaacar
Copy link

runsql jobtype

The job can be used for running sql statements against Vertica and Mysql.

  • Job files of 'runsql' type may have following parameters:
Parameter Value Comment
db Parameter for the database (*) Vertica or Mysql (Default: Vertica)
type runsql
file name_of_sql_file
working.dir /path/to/sql/file Optional (Default: Current directory of '.job' file)
param.extra Parameter for sql statement Optional (One or more)

* db value will be used for getting related values from private.properties file. One must change db-param in the next section with this db value.)

  • Property files of 'runsql' type may have following parameters:
Parameter Value Comment

| db.db-param.user | User of the database | |
| db.db-param.pass | Pass of the user | |
| db.db-param.host | Host address of the database | |
| db.db-param.db | Name of the database | |
| db.db-param.type | Type of the database | Vertica or Mysql |
| db.db-param.backupservernode | Addresses of back up server nodes | Use only for Vertica (Comma separated) |

* Parameters other than jobtype.class can be defined multiple times with a different db-param value.

An example job and property files:

Test.job
---------
    db=test
    type=runsql
    file=test.sql
    working.dir=/home/test/
Test2.job
----------
    type=runsql
    file=test.sql
    working.dir=/home/vertica/test/
Test3.job
----------
    db=prod
    type=runsql
    file=prod.sql
    param.x=5
    param.y=text
private.properties
-------------------
    db.prod.user=admin
    db.prod.pass=admin
    db.prod.host=host1
    db.prod.db=vertica-prod
    db.prod.type=vertica
    db.prod.backupservernode=host2, host3, host4

    db.test.user=admin
    db.test.pass=admin
    db.test.host=host5
    db.test.db=mysql-test
    db.test.type=mysql

    db.vertica.user=admin
    db.vertica.pass=admin
    db.vertica.host=host5
    db.vertica.db=vertica-test
    db.vertica.type=vertica

How to Use Parameters ?

After defining param.param_name parameter of a job, all substrings of related sql statement matching with {{param_name}} will be replaced by the value of the parameter.

  • Example:
    Test.job
    ---------
        type=runsql
        file=test.sql
        param.x=30
        test.sql
        ---------
            SELECT COUNT(*) FROM people WHERE age > {{x}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant