Skip to main content

AWS Athena 的 SQL 迁移

项目描述

芭蕾舞女演员

AWS Athena 的 SQL 迁移

安装

pip install athena-ballerina

用法

migrations_directory表单的一些目录在哪里:

./migrations
  1_up.sql
  1_down.sql
  2_up.sql
  2_down.sql
  3_up.sql
  3_down.sql

其中迁移文件可以是 python 格式的字符串。在此示例中,如果使用标志指定参数s3_uri,则将替换 为:s3://some-bucket/path/to/db-p s3_uri s3://some-bucket/path/to/db

CREATE EXTERNAL TABLE partitioned_table (
    col_a STRING,
    col_b TIMESTAMP,
    col_c DATE
)
PARTITIONED BY (part_key STRING)
STORED AS PARQUET
LOCATION "{s3_uri}/partitioned_table"
tblproperties ("parquet.compress"="SNAPPY");

命令行界面

usage: ballerina.py [-h] [-m MIGRATION_URI] [-s STAGING_URI] [-w WORK_GROUP]
                    [-d DBNAME] [-D DELIM] [-p PARAM PARAM]
                    [--aws_access_key_id AWS_ACCESS_KEY_ID]
                    [--aws_secret_access_key AWS_SECRET_ACCESS_KEY]
                    [--aws_session_token AWS_SESSION_TOKEN]
                    [--aws_region_name AWS_REGION_NAME]
                    [--aws_profile_name AWS_PROFILE_NAME] [-a AUTO_APPLY_DOWN]
                    [-c AUTO_CLEAN_UP] [-v]
                    migrations_directory

positional arguments:
  migrations_directory  Path to directory containing migrations

optional arguments:
  -h, --help            show this help message and exit
  -m MIGRATION_URI, --migration_uri MIGRATION_URI
                        S3 Migration Dir. (i.e: "s3://my-
                        bucket/path/to/folder/")
  -s STAGING_URI, --staging_uri STAGING_URI
                        Athena Staging dir URI (i.e: "s3://my-
                        bucket/path/to/folder/")
  -w WORK_GROUP, --work_group WORK_GROUP
                        Athena Work Group
  -d DBNAME, --dbname DBNAME
  -D DELIM, --delim DELIM
                        Delimiter used in S3 bucket.
  -p PARAM PARAM, --param PARAM PARAM
                        Parameter that can be formatted into the migration
                        file. For example if "-p KEY VAL" gets passed in CLI,
                        and in the migration file there is a python-formatted
                        string like "LOCATION s3://{KEY}/", it will be
                        formatted to "LOCATION s3://VAL/"
  --aws_access_key_id AWS_ACCESS_KEY_ID
                        AWS Access Key for Boto3
  --aws_secret_access_key AWS_SECRET_ACCESS_KEY
                        AWS Access Secret for Boto3
  --aws_session_token AWS_SESSION_TOKEN
                        AWS Access Session Token for Boto3
  --aws_region_name AWS_REGION_NAME
                        AWS Region Name for Boto3
  --aws_profile_name AWS_PROFILE_NAME
                        AWS Profile Name for Boto3
  -a AUTO_APPLY_DOWN, --auto_apply_down AUTO_APPLY_DOWN
                        Accepts True/False, default is True
  -c AUTO_CLEAN_UP, --auto_clean_up AUTO_CLEAN_UP
                        Should Athena Queries be clean-up from S3
                        OutputLocation? Accepts True/False.
  -v, --version         show program's version number and exit

芭蕾舞女演员是全有或全无。

例如,您在修订版 5 的主分支上,并且想要切换到最新修订版为 4' 的功能分支。

1 <- 2 <- 3 <- 4 <- 5  
       \
         3' <- 4' 

通过 Ballerina 应用迁移将使您处于修订版 5(如果遇到错误)或修订版 4'(如果迁移成功),但不会停留在 4、3、2 或 3' 中的任何一个。

在本地机器上测试

  • 查看docs/testing.md

执照

版权所有 2020 LeanTaas, Inc.

根据 Apache 许可证 2.0 版(“许可证”)获得许可;除非遵守许可,否则您不得使用此文件。您可以在以下网址获取许可证的副本

http://www.apache.org/licenses/LICENSE-2.0

除非适用法律要求或书面同意,否则根据许可分发的软件将按“原样”分发,没有任何明示或暗示的保证或条件。有关许可下的特定语言管理权限和限制,请参阅许可。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

athena-ballerina-0.0.6.tar.gz (9.1 kB 查看哈希)

已上传 source