Giter Club home page Giter Club logo

Comments (5)

yruslan avatar yruslan commented on June 26, 2024

Yes, you can use

SparkUtils.flattenSchema(df)

def flattenSchema(df: DataFrame, useShortFieldNames: Boolean = false): DataFrame = {

from cobrix.

elhadi412 avatar elhadi412 commented on June 26, 2024

Can we use this if our code base is in python? I believe we can use something like py4j, but is there another easier way?

from cobrix.

yruslan avatar yruslan commented on June 26, 2024

We haven't tried this, but you might be able to use the method from the JVM to Python gateway (sc._gateway.jvm...) the same way PySpark interacts with Scala codebase.

Alternatively, the source code for the flattening is not too big, you can covert it in Python for your use. If you want, you can also contribute the Python version of the flattening code to Cobrix, we can include as one of the examples.

from cobrix.

elhadi412 avatar elhadi412 commented on June 26, 2024

Sorry for the late reply. Can you show a snippet of how the call from the JVM to Python gateway would work?
Regarding contribution, I do not have the bandwidth at the moment.

from cobrix.

yruslan avatar yruslan commented on June 26, 2024

I actually haven't tried this specifically with the flattening code. I might check it out and let you know if it worked

I expect something like:

        sc = self.spark.sparkContext
        flat_java_df = sc._gateway.jvm.za.co.absa.cobrix.spark.cobol.utils.SparkUtils.flattenSchema(df._jdf)
        flat_df = spark.createDataFrame(flat_java_df)

ensuring Cobrix libraries are in the class path.

from cobrix.

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.