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

[CT-2931] TypeError: > not supported between str and int when attempting to build a dbt project #8312

Closed
2 tasks done
brian-custer opened this issue Aug 3, 2023 · 14 comments
Labels
bug Something isn't working wontfix Not a bug or out of scope for dbt-core

Comments

@brian-custer
Copy link

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

I have a dbt project with numerous staging files and whenever I attempt to build the project I get the sam error as described. It appears to be a bug because the specific error is a python error and not a dbt error.

Expected Behavior

dbt builds without issue or the issue is described in the error message enabling me to respond.

Steps To Reproduce

  1. In a virtual environment with dbt-core and dbt-databricks installed
  2. Execute dbt build and the error appears

Relevant log output

No relevant log output is generated.

Environment

- OS: Windows 11
- Python: 3.10
- dbt: 1.5.4

Which database adapter are you using with dbt?

other (mention it in "Additional Context")

Additional Context

dbt-databricks

@brian-custer brian-custer added bug Something isn't working triage labels Aug 3, 2023
@github-actions github-actions bot changed the title TypeError: > not supported between str and int when attempting to build a dbt project [CT-2931] TypeError: > not supported between str and int when attempting to build a dbt project Aug 3, 2023
@brian-custer
Copy link
Author

I am trying to finish a project with a deadline so any help would be appreciated.

@dbeatty10
Copy link
Contributor

Could you provide any more log output? Specifically, we'd be looking a filename and line number for the underlying Python exception.

Your logs/dbt.log may have more details.

Alternatively, setting the log level to debug should provide more verbose output:

dbt --log-level debug build

@brian-custer
Copy link
Author

brian-custer commented Aug 3, 2023 via email

@dbeatty10
Copy link
Contributor

Thanks for including the log from the console. I didn't see the TypeError in that output though -- was it missing once you used the dbt --log-level debug?

Do you have access to logs/dbt.log? If so, could you search for TypeError within that file to see if there's a Python stacktrace with file path or line numbers?

@brian-custer
Copy link
Author

brian-custer commented Aug 3, 2023 via email

@dbeatty10
Copy link
Contributor

Thanks for getting that stacetrace @brian-custer 👍

It looks like the args dictionary has some mixed-type keys here which is raising an error when it's being sorted.

Do you have any custom generic tests defined? Or are you using any of the four out-of-the-box tests (not_null, unique, accepted_values, or relationships)?

@dbeatty10
Copy link
Contributor

@brian-custer Could you check your YAML files for any lines that start with an integer key? If so, then I think we've found the source of the issue within your project.

Reprex ("reproducible example")

I was able to get a TypeError: '<' not supported between instances of 'int' and 'str' error message when I with a simple setup like below and then running dbt test:

models/my_model.sql

select 1 as id

models/_models.yml

models:
  - name: my_model
    columns:
      - name: id
        tests:
          - accepted_values:
              values: [1]
              1: asdf

Note the very last line in the YAML file that 1: asdf: it is completely extraneous, and everything works correctly if I remove it.

Could you see if you have anything that looks similar and try to remove it?

@brian-custer
Copy link
Author

brian-custer commented Aug 3, 2023 via email

@brian-custer
Copy link
Author

brian-custer commented Aug 4, 2023 via email

@dbeatty10
Copy link
Contributor

Could you share what you are using for your accepted_values configuration?

It should look something like this:

models:
  - name: orders
    columns:
      - name: status
        tests:
          - accepted_values:
              values: ['placed', 'shipped', 'completed', 'returned']

      - name: status_id
        tests:
          - accepted_values:
              values: [1, 2, 3, 4]
              # To test non-strings (like integers or boolean values) explicitly set the quote config to false.
              quote: false

@dbeatty10 dbeatty10 removed the triage label Aug 4, 2023
@brian-custer
Copy link
Author

brian-custer commented Aug 4, 2023 via email

@dbeatty10
Copy link
Contributor

Could you share what you are using for your accepted_values configuration? I'll be able to help you troubleshoot better if I can see your exact configuration rather than only an error message.

I'm guessing you need to add some indentation in front of your values and quote keys.

e.g., This works:

        # This works:
        tests:
          - accepted_values:
              values: [1, 2]
              quote: false

But this will give an error like you described:

        # This doesn't:
        tests:
          - accepted_values:
            values: [1, 2]
            quote: false

@brian-custer
Copy link
Author

brian-custer commented Aug 4, 2023 via email

@dbeatty10
Copy link
Contributor

I'm not encountering any more testing errors

That's good news @brian-custer ! I'm going to close out this original bug report as resolved then.

We use GitHub issues to focus on bug reports and feature requests, so definitely open up new issues as needed!

I'm just encountering the error:

SQLConnectionManager.get_result_from_cursor() missing 1 required positional argument: 'limit'

It appears to be coming from Databricks. What does this error mean and how do I fix it?

We use the dbt Community Forum for questions like "I've hit this error and am stuck", so I'm going to redirect you there instead for figuring out the new error you are running into.

Providing code examples along with the error message will help others reproduce the error and spot what the cause might be. This guide on creating reproducible examples is specific to the R community, but has great general advice too. 🧠

@dbeatty10 dbeatty10 added wontfix Not a bug or out of scope for dbt-core and removed triage labels Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix Not a bug or out of scope for dbt-core
Projects
None yet
Development

No branches or pull requests

2 participants