Git Product home page Git Product logo

Comments (3)

dosubot avatar dosubot commented on September 13, 2024 4

Hey there, @dmarkey! I'm here to help you with any bugs, questions, or contributions you have for Apache Superset. Let's tackle this issue together!

The issue you're encountering with flask_login.current_user being None during the execution of SQL_QUERY_MUTATOR in SQLLab sessions is due to differences in the execution context between SQLLab and navigating graphs. In SQLLab sessions, the user ID is explicitly retrieved and stored in the SqlJsonExecutionContext class using the get_user_id() function, rather than relying on flask_login.current_user directly [1].

To work around this, you can modify your SQL_QUERY_MUTATOR to use the get_user_id() function to retrieve the user ID. Here’s an example:

from superset.utils.core import get_user_id

def SQL_QUERY_MUTATOR(sql: str, **kwargs) -> str:
    user_id = get_user_id()
    print(user_id)  # This should print the correct user ID during a SQLLab session
    return sql

This approach ensures that you get the correct user information even in the SQLLab context.

To continue talking to Dosu, mention @dosu.

from superset.

dmarkey avatar dmarkey commented on September 13, 2024 3

That actually works.. first time I've been impressed by AI.

from superset.

dmarkey avatar dmarkey commented on September 13, 2024 2

closing

from superset.

Related Issues (20)

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.