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

Make pre commit code changes #345

Merged
merged 4 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parse = (?P<major>\d+)
\.(?P<minor>\d+)
\.(?P<patch>\d+)
((?P<prerelease>a|b|rc)(?P<num>\d+))?
serialize =
serialize =
{major}.{minor}.{patch}{prerelease}{num}
{major}.{minor}.{patch}
commit = False
Expand All @@ -13,7 +13,7 @@ tag = False
[bumpversion:part:prerelease]
first_value = a
optional_value = final
values =
values =
a
b
rc
Expand All @@ -25,4 +25,3 @@ first_value = 1
[bumpversion:file:setup.py]

[bumpversion:file:dbt/adapters/spark/__version__.py]

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ updates:
directory: "/"
schedule:
interval: "daily"
rebase-strategy: "disabled"
rebase-strategy: "disabled"
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ assignees: ''

---

### TBD
### TBD
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ resolves #
- [ ] I have signed the [CLA](https://docs.getdbt.com/docs/contributor-license-agreements)
- [ ] I have run this code in development and it appears to resolve the stated issue
- [ ] This PR includes tests, or tests are not required/relevant for this PR
- [ ] I have updated the `CHANGELOG.md` and added information about my change to the "dbt-spark next" section.
- [ ] I have updated the `CHANGELOG.md` and added information about my change to the "dbt-spark next" section.
2 changes: 1 addition & 1 deletion .github/workflows/jira-creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: Jira Issue Creation
on:
issues:
types: [opened, labeled]

permissions:
issues: write

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/jira-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: Jira Label Mirroring
on:
issues:
types: [labeled, unlabeled]

permissions:
issues: read

Expand All @@ -24,4 +24,3 @@ jobs:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/jira-transition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
secrets:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
27 changes: 13 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ name: Build and Release

on:
workflow_dispatch:

# Release version number that must be updated for each release
env:
version_number: '0.20.0rc2'

jobs:
jobs:
Test:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v2.2.2
with:
with:
python-version: '3.8'

- uses: actions/checkout@v2

- name: Test release
- name: Test release
run: |
python3 -m venv env
source env/bin/activate
Expand All @@ -38,9 +38,9 @@ jobs:
steps:
- name: Setup Python
uses: actions/setup-python@v2.2.2
with:
with:
python-version: '3.8'

- uses: actions/checkout@v2

- name: Bumping version
Expand All @@ -60,7 +60,7 @@ jobs:
author_email: 'leah.antkiewicz@dbtlabs.com'
message: 'Bumping version to ${{env.version_number}}'
tag: v${{env.version_number}}

# Need to set an output variable because env variables can't be taken as input
# This is needed for the next step with releasing to GitHub
- name: Find release type
Expand All @@ -69,7 +69,7 @@ jobs:
IS_PRERELEASE: ${{ contains(env.version_number, 'rc') || contains(env.version_number, 'b') }}
run: |
echo ::set-output name=isPrerelease::$IS_PRERELEASE

- name: Create GitHub release
uses: actions/create-release@v1
env:
Expand All @@ -88,7 +88,7 @@ jobs:
# or
$ pip install "dbt-spark[PyHive]==${{env.version_number}}"
```

PypiRelease:
name: Pypi release
runs-on: ubuntu-latest
Expand All @@ -97,13 +97,13 @@ jobs:
steps:
- name: Setup Python
uses: actions/setup-python@v2.2.2
with:
with:
python-version: '3.8'

- uses: actions/checkout@v2
with:
ref: v${{env.version_number}}

- name: Release to pypi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
Expand All @@ -116,4 +116,3 @@ jobs:
pip install twine wheel setuptools
python setup.py sdist bdist_wheel
twine upload --non-interactive dist/dbt_spark-${{env.version_number}}-py3-none-any.whl dist/dbt-spark-${{env.version_number}}.tar.gz

20 changes: 10 additions & 10 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# **what?**
# This workflow will take a version number and a dry run flag. With that
# it will run versionbump to update the version number everywhere in the
# it will run versionbump to update the version number everywhere in the
# code base and then generate an update Docker requirements file. If this
# is a dry run, a draft PR will open with the changes. If this isn't a dry
# run, the changes will be committed to the branch this is run on.

# **why?**
# This is to aid in releasing dbt and making sure we have updated
# This is to aid in releasing dbt and making sure we have updated
# the versions and Docker requirements in all places.

# **when?**
# This is triggered either manually OR
# This is triggered either manually OR
# from the repository_dispatch event "version-bump" which is sent from
# the dbt-release repo Action

Expand All @@ -25,11 +25,11 @@ on:
is_dry_run:
description: 'Creates a draft PR to allow testing instead of committing to a branch'
required: true
default: 'true'
default: 'true'
repository_dispatch:
types: [version-bump]

jobs:
jobs:
bump:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -58,19 +58,19 @@ jobs:
sudo apt-get install libsasl2-dev
python3 -m venv env
source env/bin/activate
pip install --upgrade pip
pip install --upgrade pip

- name: Create PR branch
if: ${{ steps.variables.outputs.IS_DRY_RUN == 'true' }}
run: |
git checkout -b bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_$GITHUB_RUN_ID
git push origin bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_$GITHUB_RUN_ID
git branch --set-upstream-to=origin/bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_$GITHUB_RUN_ID bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_$GITHUB_RUN_ID

- name: Bumping version
run: |
source env/bin/activate
pip install -r dev_requirements.txt
pip install -r dev_requirements.txt
env/bin/bumpversion --allow-dirty --new-version ${{steps.variables.outputs.VERSION_NUMBER}} major
git status

Expand Down Expand Up @@ -100,4 +100,4 @@ jobs:
draft: true
base: ${{github.ref}}
title: 'Bumping version to ${{steps.variables.outputs.VERSION_NUMBER}}'
branch: 'bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_${{GITHUB.RUN_ID}}'
branch: 'bumping-version/${{steps.variables.outputs.VERSION_NUMBER}}_${{GITHUB.RUN_ID}}'
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
alias: flake8-check
stages: [manual]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
rev: v0.950
hooks:
- id: mypy
# N.B.: Mypy is... a bit fragile.
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
recursive-include dbt/include *.sql *.yml *.md
recursive-include dbt/include *.sql *.yml *.md
5 changes: 2 additions & 3 deletions dbt/adapters/spark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
from dbt.include import spark

Plugin = AdapterPlugin(
adapter=SparkAdapter,
credentials=SparkCredentials,
include_path=spark.PACKAGE_PATH)
adapter=SparkAdapter, credentials=SparkCredentials, include_path=spark.PACKAGE_PATH
)
25 changes: 11 additions & 14 deletions dbt/adapters/spark/column.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from dataclasses import dataclass
from typing import TypeVar, Optional, Dict, Any
from typing import Any, Dict, Optional, TypeVar, Union

from dbt.adapters.base.column import Column
from dbt.dataclass_schema import dbtClassMixin
from hologram import JsonDict

Self = TypeVar('Self', bound='SparkColumn')
Self = TypeVar("Self", bound="SparkColumn")


@dataclass
Expand All @@ -31,7 +31,7 @@ def literal(self, value):

@property
def quoted(self) -> str:
return '`{}`'.format(self.column)
return "`{}`".format(self.column)

@property
def data_type(self) -> str:
Expand All @@ -42,26 +42,23 @@ def __repr__(self) -> str:

@staticmethod
def convert_table_stats(raw_stats: Optional[str]) -> Dict[str, Any]:
table_stats = {}
table_stats: Dict[str, Union[int, str, bool]] = {}
if raw_stats:
# format: 1109049927 bytes, 14093476 rows
stats = {
stats.split(" ")[1]: int(stats.split(" ")[0])
for stats in raw_stats.split(', ')
stats.split(" ")[1]: int(stats.split(" ")[0]) for stats in raw_stats.split(", ")
}
for key, val in stats.items():
table_stats[f'stats:{key}:label'] = key
table_stats[f'stats:{key}:value'] = val
table_stats[f'stats:{key}:description'] = ''
table_stats[f'stats:{key}:include'] = True
table_stats[f"stats:{key}:label"] = key
table_stats[f"stats:{key}:value"] = val
table_stats[f"stats:{key}:description"] = ""
table_stats[f"stats:{key}:include"] = True
return table_stats

def to_column_dict(
self, omit_none: bool = True, validate: bool = False
) -> JsonDict:
def to_column_dict(self, omit_none: bool = True, validate: bool = False) -> JsonDict:
original_dict = self.to_dict(omit_none=omit_none)
# If there are stats, merge them into the root of the dict
original_stats = original_dict.pop('table_stats', None)
original_stats = original_dict.pop("table_stats", None)
if original_stats:
original_dict.update(original_stats)
return original_dict
Loading