Tag: syndicated

  • Writing Parquet Files – #SQLNewBlogger

    Recently I’ve been looking at archiving some data at SQL Saturday, possibly querying it, and perhaps building a data warehouse of sorts. The modern view of data warehousing seems to be built on using a Lakehouse architecture where data moves through different phases, but much of the data is stored in text files, often parquet files.

    As a start to this I decided to try and move data to parquet. This post looks at writing parquet files.

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    Writing Parquet Files

    In a previous post I looked at reading in JSON data, which is how some of my data is archived. I also talked about importing modules. There is a module, called pyarrow, that allows me to work with various parts of Apache Arrow.

    One of the submodules in pyarrow is the parquet module, which lets me read and write parquet files. So, let’s get those modules.

    import pyarrow as pa
    import pyarrow.parquet as pq

    I am giving these show names so I can refer to them in code. Now, let’s skip the code from the previous article and assume I’ve got a dataframe with my sessions in it. How do I get a parquet file?

    Fortunately, I don’t need to know anything about the physical structure, as I can use the write_table() function from the parquet module to do that. I’ll also use the pyarrow.Table.from_pandas() function to get data from the dataframe into this module. This code does that (with some setup for a filename).

        outputFilename = f + '.parquet'
        outputFile = join(outPath, outputFilename)
        pqtable = pa.Table.from_pandas(df)
    # Write Arrow Table to Parquet file
        pq.write_table(pqtable, outputFile)

    Note: I don’t know the technical differences between how pandas dataframes and the pyarrow tables work. I found a few notes online and it looks like pyarrow tables can handle more complex data structures.

    Once this code is added to the code from the previous article (it’s already indented), this will write .parquet files to the bronze folder underneath the location from where it is run. In essence, this takes data from the raw folder and writes it to bronze in a new format.

    Summary

    This post shows how to write parquet files out from JSON data. Take the previous article and this one and you can move data from JSON to parquet.

    This code isn’t perfect. In fact, it needs work. I am only moving session data, so only a portion of the JSON data. This code should be enhanced, or the file names changed to reflect that, but for now, this is a quick example of producing parquet data.

    SQL New Blogger

    This post took about 10 minutes to write once I had the code working. In fact, adding these functions to the code from the last article only took a few minutes. I had to debug a few things to get the files into the correct folder, but it took longer to get these words down than get code working.

    Not a lot longer, but longer.

    You can do this. If you want to work in modern technologies, learn them. Learn how to work with parquet, which is being used a lot in data warehousing, and then write about it. Prove you can get things done and your current employer, or your next one, might give you a project to actually do this work.

  • A New Word: Flichtish

    flichtish – adj. nervously aware how much of your self-image is based on untested assumptions about yourself – only ever guessing how you’d react to a violent thread, a sudden windfall, a huge responsibility, or being told to do something you knew was wrong..

    I used to think I had all the answers and knew how I’d react to situations or what type of person I was.

    I was a teenager. I think this view is fairly common among teenagers, but also in older people. I see too many people with confidence in how they’d react to an unknown.

    And I see too often they don’t actually react that way. The more self-aware people recognize that their self-image was untested and wrong. The less self-aware people think the situation was an anomaly.

    I know that until I walk a mile in my shoes in some situation, I’m very un-tested. I have a guess as to what my self-image is, but I doubt it is 100% true. As Mike Tyson says, everyone has a plan until they get punched in the mouth. Flichtish is a recognition of that saying.

    From the Dictionary of Obscure Sorrows

  • The Ireland and UK DevOps Roadshow

    We’re taking the roadshow across the water. Hope the plane makes it.

    AUS02544

    The Redgate DevOps Roadshow comes to Ireland and the Northern UK in June. We’ll be in these cities on these dates:

    • June 11 – Dublin (Grant)
    • June 13 – Glasgow (Grant)
    • June 14 – Manchester (Steve)

    We’ll also have one of Redgate’s amazing Solution Engineers, Huxley Kendall. He’ll be there to answer in-depth questions on the products and solutions that Redgate offers.

    This is a great chance to get exposure to the solutions Redgate offers for building and managing your database code, as well as ask questions about the challenges you face and how we might tackle them.

    Register today and join us for a great day in one of these cities.

  • T-SQL Tuesday #174 – My Favorite Interview Question

    This month is a great topic to me. I think growing and improving your career is a skill that most of  us could improve, especially in our younger years. The invitation from Kevin Feasel is a good one from which you can learn a lot.

    I am looking forward to the responses from others.

    If you want to host an invite one month, ping me and request a date. Most of 2024 is full, but I have a few months, and I certainly am happy to schedule you into 2025. This is a great way to participate in the community, meet others, and challenge yourself. You just need a blog.

    In this post I’m going to give two questions, one as an interviewer and one as interviewee.

    My Favorite Interview Question for Candidates

    When I interview someone, I usually have a list of things to ask them to better help me compare candidates, but these are associated with digging into knowledge, however this question really helps me.

    What have you learned recently?

    I don’t expect candidates to know everything. I expect to have to teach them quite a bit about my environment. However, what I want from them is an effort to learn. My view is that some people are constantly learning things and others are content to rest on their previous knowledge/experience.

    If someone hasn’t learned anything recently, I don’t necessarily write them off, but I might probe about what they have been doing, as well as how they prepared for a new job or the interview. Perhaps they’ve been busy with something (crisis, illness, etc.) and haven’t been improving in the short term, but if someone hasn’t learned anything in the last year they’re proud of, or they can’t remember when they last invested in themselves, I have a hard time investing in them as an employee.

    Note, I will dig into ensure you learned something and aren’t just giving me an answer.

    My Favorite Question as an Interviewee

    In a lot of my jobs as a technologist, or a data professional, the job is the job. It’s very similar in many places. These days I do more architecture and advocacy, but if I were approaching a new job, I’d ask this:

    What are the expectations around working hours?

    I’d add context to this, but what I’m looking for are information for these items:

    • core working hours
    • on-call/non-core hours
    • punctuality

    I don’t mind working hard, but I don’t expect to work a lot of non-core hours every week, or even too regularly. I don’t mind 40 or even 50, but beyond that I’m not going to be happy.

    I’m also not someone that punches a clock. If you expect me to be online (or in an office) every day at 8am, you’re going to be disappointed. I might be there at 7:45 or 8:15. I don’t avoid work, and I do my best to be early for meetings, but if nothing is scheduled, I will vary my start time. I usually warn a potential boss about this.

    I used to ask about travel, but I’m over that. I don’t mind or worry about travel too much.