Category: Blog

  • Moving One File Across Git Branches: #SQLNewBlogger

    I was working on some branching and merging with a customer and they wanted to move a file from one branch to another without taking the entire commit. I had to dig in a bit and see how to cherry pick a file, and not a commit. This post looks at how this can work.

    I’ll do this in the git CLI. I’m sure it works in many clients, but when I do something strange or new, I like looking at the CLI. Mostly because when I make a mistake, the clients send me to the CLI often anyway, so I get comfortable there.

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers. You can see all posts on Git as well.

    A Simple Setup

    First, grab a repo. In this case, I had a branching/merging repo I use with customers to show some things. I’ll use the repo at: https://github.com/way0utwest/BranchMerge

    For me, I have a main branch, as well as a dev and qa branches. There are likely some feature ones as well.

    To start with, let’s check main. Everything is up to date (I pulled already):

    2024- 08_ 0059

    Let’s also check QA. Same thing.

    2024- 08_ 0060

    I’ll now make some changes on QA, adding a file and changing two others. Once I do this, here is my status, pre-commit.

    2024- 08_ 0061

    If I don’t commit, these files don’t exist, and I could change branches and add them there. However, once I commit, I might want to move them in a certain way. I’ll commit and my status is clean.

    2024- 08_ 0062

    Now, I could switch to main and do this to move one file:

    git checkout qa -- README.md

    However, I’m just doing that without review. So, I wouldn’t do that and you shouldn’t either. Instead, let’s create a PR.

    Using a Branch for Peer Review

    A PR is a pull request, but it also means we ask for some peer review. In my case, I’ll use this code to create a new branch and then pull in two changes: my modified readme and one of the other changes.

    git checkout -b r9-qa

    git checkout qa -- README.md

    git checkout qa -- "V6__create proc gettwo.sql"

    Ignore my typos, but I’ve run 4 commands: checkout 3 times and status once.

    2024- 08_ 0063

    Now I’ll commit and push these changes to my r9-qa branch.

    2024- 08_ 0064

    Once I do that, Github detects a push and asks me to create PR. I do, and I see the PR with these changes.

    2024- 08_ 0065

    Now I can proceed with my flow, and my cherry picked changes are captured.

    There is a git cherrypick command, but often I find I need random files from multiple commits, while ignoring others in the commit. This works well for database releases.

    A few references:

    SQL New Blogger

    This post took my about 20 minutes to write. However the learning and experimentation took over an hour as I read various links and dug into the docs and various posts.

    This is a very useful skill, and one you can discuss in an interview. Write a similar post and you’ll be prepared for this type of question in an interview.

  • Creating a Synapse Workspace

    As part of my job, I needed to research how a few things work with Synapse and Fabric. The latter includes the former, mostly. I decided to setup a workspace and a do some experimentation.

    My first stop was the Stairway to Synapse Analytics. I started with Level 1, since I needed to create something.

    In the portal, I created a new Synapse Analytics resource. I won’t go into details, but basically create a new resource and search. Read the article to see how this works. From there, I used a resource group I had for work stuff. I also had to create a new Data Lake Storage Gen2 account. I didn’t bother with the Managed Resource Group.

    2024- 08_ 0039

    I added a user account and password and then clicked Create. I went to the summary page, where I could see the small cost for serverless. I clicked “Create” again to start the deployment.

    2024- 08_ 0041

    The deployment failed.

    2024- 08_ 0042

    I was leaning towards this not being helpful, but I went into the details of the error message and found something interesting. My subscription couldn’t deploy in this region (westeurope).

    2024- 08_ 0048

    OK, go back, recreate the resource in UKSouth. That worked fine and I saw my resources.

    2024- 08_ 0046

    At this point, I had a resource.

    Adding Data

    The next step for me was to add some data. I grabbed a few csv files and uploaded them to my storage account. Lots of querying in Synapse is through external tables to flat files, so I picked some files I can query.

    2024- 08_ 0049

    Once these were uploaded, I was next interested to see if I could query this data. In my main Synapse resource, I see some endpoints.

    2024- 08_ 0050

    I copied the serverless one and then opened SSMS. I put this, my user and pwd, and got connected. I was hoping that @@Version would tell me I was connected to Synapse, but I got the same results I get some Azure SQL Database, albeit with a different timestamp. However, ServerProperty() helps.

    2024- 08_ 0052

    That works, what about my data? Let’s try a query from Level 2.

    I’ll take this query and run it. I’ve adjusted this from the values in Level 2, which actually uses the Synapse Workspace explorer online.

    –retrieve data from csv file

    SELECT
    TOP 100 *
    FROM
    OPENROWSET(
    BULK 'https://synapsesqlprompt.blob.core.windows.net/sqlpromptfs/solar_2024_01.csv',
    FORMAT = 'CSV',
            HEADER_ROW = TRUE,
            PARSER_VERSION = '2.0'
        )
    WITH (
        [Time]  DATE,
        [System Production (Wh)] VARCHAR (100)
        ) AS [result]

    It fails.

    2024- 08_ 0053

    Hmmm, let’s try that in the browser. Here it works.

    2024- 08_ 0054

    The error is with a credential.

    There is a quickstart online, and that query works. However, there is a note in the query that I need a credential if my file is protected.

    2024- 08_ 0055

    The article had this link and used the sample code to create a credential:

    CREATE CREDENTIAL [https://synapsesqlprompt.blob.core.windows.net/sqlpromptfs]
    WITH IDENTITY='SHARED ACCESS SIGNATURE'
    , SECRET = '';
    GO

    Now I can run my original query and it works.

    2024- 08_ 0056

    That was a pretty cool exercise for me to get started. In less than 30 minutes I was able to create a Synapse workspace, add some data, and query it.

    Now to learn a bit more about how this works, and to use Flyway to deploy some objects.

  • One Month with the Dell Latitude 7450

    It was just over a month ago that I got a Dell Latitude 7450 from our corporate IT group. It wasn’t my first choice, but as Redgate grows, they’re trying to be more secure and standard. I didn’t have a good reason to not try it, to I agreed to give it a try. My boss said if it was a problem, we’d get an exception and I’d choose another one. I had hoped for another HP Spectre, but this really is just a toaster to me. I need it to just work.

    The Design

    This is a bit heaver than my old Spectre, but also larger. It also has more ports.

    I got the laptop, so it doesn’t fold over into a book or tablet or tent. I had thought that might be useful at times, but in 8 years of two Spectre versions that opened past 10 degrees, I think I’ve done that 5 times.

    The screen is nice and works well for me. I like that I have both USB C and USB B ports on the laptop. I wish I had one of each on each side, but I have 2 Cs on the left and 2 Bs on the right. It’s a very minor gripe.

    I do like I have an HDMI port built in, which is something my Spectre was missing. This means I can take something else out of my travel kit.

    I got this with 32GB of RAM, which is probably a good reason why Windows 11 runs smoothly here. I also got a 1TB drive, which is overkill. I had a 512 in the last machine and after 5 years, I still had space.

    The keyboard is OK, fairly standard, backlit, and responds well. The trackpad is large, and seems to work well with the left/right clicks.

    The touchscreen is good and it also works with a pen, and I got an Active one from Amazon that I’ve used in whiteboard sessions with customers.

    Annoyances

    The big thing was the trackpad for me. It is a little sensitive and if a finder or hand brushes it, I get some weird actions. Mostly I do something the causes windows to minimize, which is really annoying. I’ve tried tuning down some of the actions, but I need to do more. It doesn’t cause too many problems, but enough that it’s on my mind.

    The Home and End keys moved to the top row. They were on the side of my old machine, and I was used to those. I still can’t quite hit home and end without looking, or without hitting insert. I also lost my page up/down keys as well. I can use Funtion+up arrow (or down), but that’s not something I think about.

    Concerns

    I’ve had 2 blue screens coming out of a closed machine in a month. The system was unresponsive once and when I tried to CTRL+ALT+DEL it blue screened after a few minutes.

    I’m keeping an eye on it. This might be my machine or this model, but if I get a few more, I might need to replace it.

    Overall

    Overall I learned that I don’t really care anymore about a laptop. It’s a tool, and I need it to work, but I’m not that wedded to the hardware. They keyboard matters to me, but of a bunch I tested, they were all find enough. Small differences, but overall they worked.

    Other than that, this thing works well and runs fine. I still think some of the Win11 stuff that changed wasn’t an improvement and I need to figure out if I can turn some things off, but it works well.

    I’d get another one of these without complaints. Assuming the blue screens stop.

  • A New Word: Midding

    midding – n. the tranquil pleasure of being near a gathering but not quite in it – hovering on the perimeter of a campfire, talking quietly outside a party, resting your eyes in the back seat of a car listening to friends chatting up front – feeling blissfully invisible yet still fully included, safe in the knowledge that everyone is together and everyone is okay, with all the thrill of being there without the burden of having to be.

    I thinking I feel midding all the time, often with family or friends. My wife, my oldest, and some friends often talk a lot and dominate a conversation. I can be happy to be there, adding bits here and there, but often being a bit on the outside.

    I see lots of tech professionals at conferences or user groups comfortable with midding, being around other conversations, perhaps standing near others, but not a part of the conversation. But still involved, trying to learn or glean some insight from what others are talking about.

    I think midding is a nice community feeling, and the data platform world, at least in the Microsoft space, has been very open here. We welcome others to hang out and learn or listen or just be entertained. I think that’s great.

    I also think that at least some of the time you need to leave behind the midding and actively engage in the gathering.

    From the Dictionary of Obscure Sorrows