Git Product home page Git Product logo

builder-to-query-launcher's Introduction

builder to BQ

Using project

Argument

positional arguments:

  • build_type : Name of builder use-case, Datamart or Referential table
  • entity_name : Name of entity use-case
  • path_destination_bq : project_id.dataset_id.table_id

optional arguments: -h, --help show this help message and exit

  • -date_begin : DATE_BEGIN, Date begin of partition date in BQ
  • -date_end DATE_END, Date end of partition date in BQ
  • -table_source TABLE_SOURCE, project_id.dataset_id.table_id
  • -action_utils ACTION_UTILS; Name of action for utils manager

Values

  • build_type = datamart , referential_table or utils
  • entity_name = Name of entity for call query.sql from Factory Model : insights_client, InsightsVente, InsightsStock, referential_product, InsightsEcommerce,EcommerceAgg etc ... entity_name is value giving in config.json (resources/config/config.json)
  • table_source =
  • date_begin = Date of query need to begin : "2020-10-09"
  • date_end = Date of query need to end : "2020-10-10"
  • destination_table = Path of destination query to write in BigQuery : "project_id.dataset_id.table_id"

Configuration :

Your can create new use-case in resources/config/config.json by following the existing file.

Config Json explain :

{
  "utils": {
    "SensorDate": {
      "sql_init": "resources/usecase/sensor/sensor_data/sensor_bq.sql"
    }
  },
  "a_referential_table": {
    "ReferentialEcommerceProduct": {
      "sql_init": "resources/usecase/a_referential_table/referential_ecommerce_product/query_referential_ecommerce_product_init.sql"
    },
    "sql_current": "resources/usecase/a_referential_table/referential_ecommerce_product/query_referential_ecommerce_product.sql"
  },
  ...
  "b_datamarts": {
    "InsightsEcommerce": {
      "fnac_sql": "resources/usecase/b_datamarts/insights_ecommerce/fnac/sql/query_insight_ecommerce_fnac.sql",
      "darty_sql": "resources/usecase/b_datamarts/insights_ecommerce/darty/sql/query_insight_ecommerce_darty.sql"
    }
  },
  "c_dashboard": {
    "EcommerceAgg": {
      "sql_init": "resources/usecase/c_dashboard/ecommerce/sql/insights_ecommerce_agg.sql"
    },
    ...
  }
}

to demystify the config.json :

{
  "utils": {
    "SensorDate": {
      "give_key_name": "sql_path"
    }
  },
  "folder_name_path": {
    "entity_name": {
        "sql_file":{
            "sql_path ": "give_value"
        },
        "write_disposition": "give_value",
        "field_time_partitioning": "give_value", 
        "query_builder": "give_value"
    }
  }
}
  • 'sql_init' key is checking from Factory Class in the case of referential tables but not for all datamarts, so the key that matches the config.json path can be any name
  • 'fnac_sql' & 'darty_sql' is specific key case to insights clients.

Launch project from python :

Launch python from line :

python -m src.main  <build_name> <entity_name> <source_table> -date_begin=<date_begin> -date_end=<date_end> <destination_table>

or

python -m src.main  <build_name> <entity_name> <source_table> -date_begin=<date_begin> -date_end=<date_end> -action_utils=<action_utils> -table_source=<table_source> <destination_table>

Example :

python -m src.main -date_begin="2019-01-01" -date_end="2019-01-30" "utils" "DataCatchUp" -action_utils="ReferentialEcommerceProduct" "plateforme-fournisseurs-prod.referential_table.referential_ecommerce_product"

Datamart & Referential

Insights

python -m src.main -date_begin="2019-01-01" "b_datamarts" "InsightsEcommerce" "project_id.dataset_id.table_id"
python -m src.main -date_begin="2021-05-01" -date_end="2021-05-31" "b_datamarts" "InsightsClient" "plateforme-fournisseurs-prod.dev.insights_clients"

Referential

python -m src.main -date_begin="2019-01-02" "referential_table" "ReferentialStockProduct" "plateforme-fournisseurs-prod.preprod.referential_stock_product"

utils

BigQuery Tools

python -m src.main "utils" "BqUtils" -action_utils="create_dataset" "plateforme-fournisseurs-prod.c_dashboard"

Sensor Tools

python -m src.main -date_begin="2021-04-20" "utils" "SensorDate" "plateforme-fournisseurs-prod.data.stock"
python -m src.main -date_begin="2021-08-15" "utils" "SensorDate" -field_name_sensor="import_date" "plateforme-fournisseurs-prod.data.clients_fnac_niv4__all_versions"
python -m src.main "utils" "SensorRow" -field_name_sensor="import_date" "plateforme-fournisseurs-prod.referential_table.referential_user_fournisseur" 

data Catch up

python -m src.main -date_begin="2019-01-01" -date_end="2019-01-30" "utils" "DataCatchUp" -use_case_target="b_datamarts" -action_utils="InsightsEcommerce" "plateforme-fournisseurs-prod.dev.referential_ecommerce_product"

Using Docker

Build Dockerfile

docker build . -t builder-to-bq

Run Dockerfile

docker run -p 80:80 -d builder-to-bq

Delete processus docker

docker rm -f $(docker ps -a -q )

License

The source code of this program is dual-licensed under the EUPL v1.2 and AGPLv3 licenses.

builder-to-query-launcher's People

Watchers

Manitra RANAIVOHARISON avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.