<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vladimir Poliakov on Medium]]></title>
        <description><![CDATA[Stories by Vladimir Poliakov on Medium]]></description>
        <link>https://medium.com/@v.poliakov?source=rss-10ccf113b74f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xWRDEEIZcbPOCoxz8lma3w.jpeg</url>
            <title>Stories by Vladimir Poliakov on Medium</title>
            <link>https://medium.com/@v.poliakov?source=rss-10ccf113b74f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:41:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@v.poliakov/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Databricks SDK for Python]]></title>
            <link>https://medium.com/@v.poliakov/databricks-sdk-for-python-2cd5e33cc5f0?source=rss-10ccf113b74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cd5e33cc5f0</guid>
            <category><![CDATA[python-databricks]]></category>
            <category><![CDATA[databricks-basics]]></category>
            <category><![CDATA[azure-databricks]]></category>
            <category><![CDATA[databricks-sdk]]></category>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[Vladimir Poliakov]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 13:51:06 GMT</pubDate>
            <atom:updated>2025-09-11T13:51:06.285Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>still in Beta, but already pretty nice</strong></h4><p><strong>0. Motivation</strong></p><p>From the official docs:</p><blockquote>“The Databricks SDK for Python (Beta) includes functionality to accelerate development with Python for the Databricks Lakehouse. It covers all public Databricks REST API operations.”</blockquote><p>I have been working closely with the Databricks SDK for Python (Beta) recently. On one hand, I was really excited about what the SDK can do — it’s powerful and pretty intuitive. But on the other hand, I got a bit frustrated with the documentation. 😅</p><p>So, I decided to put together into a short a <strong>quick and friendly intro</strong> under the motto:</p><p>👉 <em>“Still in Beta, but already pretty nice.”</em></p><p>Hopefully, this saves you some time (since ChatGPT doesn’t always have the answers 😉) and helps you quickly build SQL workflows, analysis pipelines, or even orchestrate jobs.</p><p><strong>1. Getting Started</strong></p><p>First things first: follow the docs. The SDK team says:</p><blockquote>“It is highly recommended to upgrade to the latest version.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gX82ZmH-qDpnhZN2lSPBHg.png" /></figure><p>Now we can create out Databricks WorkspaceClient. And then… let’s pull the <strong>last 20 queries</strong> from your workspace with just a few lines of code.</p><p>Not bad, right? 😁</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m1EinEh4VSkDEVg5PTlmCA.png" /></figure><p><strong>2. Creating Queries (and maybe Dashboards)</strong></p><p>The Databricks SDK for Python (Beta) is great — but doesn’t completely support creating visualizations or dashboards directly in Databricks. The recommended approach is to build them manually. So, you’ll still need to do that manually in Databricks UI. But imagine how cool it would be to automatically generate a dashboard with key performance statistics and share it with your business stakeholders or team!</p><p>At this moment (September 2025), we can at least create and run queries (based on our Dataframe above) programmatically — so let’s try that. 😉</p><pre>from databricks.sdk import WorkspaceClient<br>from databricks.sdk.service.sql import Query<br><br># Magic begins 😉 Create a Workspace client with default credentials of the current user<br>wc = WorkspaceClient()<br><br>tool_prefix_name = &quot;Databricks SQL and Performance Analyzer&quot;<br><br>query_catalog = &quot;perf_analyzer_cat&quot;<br>query_schema = &quot;default&quot;<br>query_table_name = &quot;query_history_table&quot; <br>query_display_name = f&quot;{tool_prefix_name} - Query Duration Overview&quot;<br><br># save as table the dataframe getting above<br>df.write.mode(&quot;overwrite&quot;).saveAsTable(f&quot;{query_catalog}.{query_schema}.{query_table_name}&quot;)<br><br># delete the old query if exists befor create to avoid duplicates<br>queries = wc.queries.list()<br>for q in queries:<br>    if q.display_name == query_display_name:<br>        print(f&quot;Old Query with id {q.id} found and will be moved to trash&quot;)<br>        wc.queries.delete(q.id)<br>        print(f&quot;Old Query with id {q.id} moved succefully to trash&quot;)<br><br>query_text = f&quot;SELECT * FROM {query_catalog}.{query_schema}.{query_table_name} ORDER BY duration_sec DESC&quot;<br><br># create query<br>sql_query = wc.queries.create(query=Query(<br>    catalog=query_catalog,<br>    schema=query_schema,<br>    display_name=query_display_name,<br>    query_text=query_text,<br>    description=f&quot;{query_display_name} from Databricks SQL and Performance Analyzer Toolkit&quot;,<br>    warehouse_id=wc.data_sources.list()[0].warehouse_id,  # ID of the SQL warehouse attached to the query, should be just one available<br>))<br><br>print(f&quot;New Query erstellt: {sql_query.id}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nl6_99M2ucXbOzxuFDRHgA.png" /></figure><p><strong>3. Analysis of quieries</strong></p><p>Now that we’ve got the Query History data with the Databricks SDK, we can analyze it directly — or let Genie help us out. ✨Just describe the issue in natural language, and Genie suggests SQL you can refine in your SQL Performance Analyzer. Pretty cool, isn’t it? 😉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8r3Oa5SWQeidTPFJK89IZg.png" /></figure><p><strong>4. Job orchestration</strong></p><p>After exploring and browsing our queries, it’s time to take the next step: orchestrating jobs dynamically! The new Databricks SDK for Python (Beta) makes it easy to submit jobs with different parameters and run them concurrently. That means you can now build your own job orchestrator and pass parameters programmatically.</p><p>Finally, no more thousands of jobs with hardcoded parameters. I love it! 🥰</p><pre>#<br># 1. Get job id by name to start<br>#<br># Create a Workspace client with default credentials of the current user<br>wc = WorkspaceClient()<br><br># Get job id by name, because the job id will be generated new after each redeployment<br>JOB_NAME_TO_RUN = &quot;dev-hello-world&quot;<br><br>job_list = wc.jobs.list()<br><br>job_id = next( (job.job_id for job in job_list if job.settings.name == JOB_NAME_TO_RUN), None )<br><br>if job_id:<br>    print(f&quot;Job {JOB_NAME_TO_RUN} found with id {job_id}&quot;)<br>else:<br>    print(f&quot;Job {JOB_NAME_TO_RUN} not found&quot;)<br><br>#<br># 2. Submit jobs with different parameters to run concurrently<br>#<br>job_parameters_list = [<br>        {&quot;first_name&quot;: &quot;Joey&quot;, &quot;second_name&quot;: &quot;Tribbiani&quot;},<br>        {&quot;first_name&quot;: &quot;Phoebe&quot;, &quot;second_name&quot;: &quot;Buffay&quot;}<br>]<br><br># Submit jobs concurrently to run<br>for job_parameter in job_parameters_list:<br>    print(f&quot;Try to start job with job_id: {job_id} and parameters: {job_parameter}&quot;)<br>    response = wc.jobs.run_now(job_id=job_id, job_parameters=job_parameter)<br>    run_id = response.run_id<br>    print(f&quot;The job {JOB_NAME_TO_RUN} is started with run_id: {run_id}&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gGEqxaxH3FF2pY1HdPUtDg.png" /></figure><p><strong>5. Loading Job-History</strong></p><p>Since we deployed and started our jobs, it is time to monitor them. With Databricks SDK for Python (Beta), you can access much more detailed information about running and completed jobs than what is available in the standard Databricks Job Runs Dashboard.</p><p>You can:</p><p><em>- Observe all jobs or only previously executed jobs</em></p><p><em>- Filter and analyze the execution data</em></p><p><em>- Build custom dashboards tailored to your needs</em></p><p>Do not hesitate to dig deeper — you might discover insights that the default dashboard does not show. Once you start building your own monitoring views, you will love the flexibility! (I certainly do! 😁)</p><pre>from datetime import datetime, timezone<br><br># Create a Workspace client with default credentials of the current user<br>wc = WorkspaceClient()<br><br># --------------------<br># Show ALL JOBS RUNS<br># --------------------<br># It is possible to show the runs of one job filter by job_id<br># Or it possible to filter to only completed runs or only active runs<br><br># Still &#39;limit&#39; (the number of jobs to return) is not acepted in the &#39;list_runs&#39; method (DB SDK (Beta) 0.64.0), use &#39;start_time_from&#39; (Unix UTC timestamp in milliseconds) to limit / filter output<br>readable_start_time = &quot;2025-08-18 00:00:00&quot;<br>dt_start = datetime.strptime(readable_start_time, &quot;%Y-%m-%d %H:%M:%S&quot;).replace(tzinfo=timezone.utc)<br>jobs_start_time_from = int(dt_start.timestamp()*1000)<br><br>jobs = wc.jobs.list_runs(expand_tasks=False, start_time_from=jobs_start_time_from) # here is some magic 😉<br>job_list = list(jobs) # store in variable to reuse the generator<br>total_jobs = len(job_list)<br><br>print(f&quot;Total count of jobs is {total_jobs} since {readable_start_time}&quot;)<br><br>limit_show = 25 # Show only N-jobs<br>counter = 0<br>job_results = []<br>for job in job_list:<br>    counter += 1<br>    if counter &lt;= limit_show:<br>        if job.status.termination_details:<br>            termination_code = job.status.termination_details.code.value<br>            termination_message_short = job.status.termination_details.message[:40]<br>            termination_type = job.status.termination_details.type.value<br>   <br>        result = {&quot;job_run_name&quot;: job.run_name, <br>                  &quot;job_run_id&quot;: job.run_id,<br>                  &quot;job_status&quot;: job.status.state.value,<br>                  &quot;job_termination_detail&quot;: termination_code,<br>                  &quot;job_termination_message_short&quot;: termination_message_short,<br>                  &quot;termination type&quot;: termination_type}<br>        job_results.append(result)<br><br>print(f&quot;Show only {limit_show} jobs from {total_jobs}&quot;)<br>display(job_results)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SNy67uDxlk9ybiQ7slHH6g.png" /></figure><p><strong>6. Summary</strong></p><p>Databricks SDK for Python: still in Beta, but already pretty nice. Here, we only touched the surface: queries, orchestration, monitoring. There’s much more to explore.</p><p>🔗 Official docs:</p><p><a href="https://databricks-sdk-py.readthedocs.io/en/latest/index.html">https://databricks-sdk-py.readthedocs.io/en/latest/index.html</a></p><p>🔗 GitHub examples:</p><p>(<a href="https://github.com/databricks/databricks-sdk-py/tree/main/examples">https://github.com/databricks/databricks-sdk-py/tree/main/examples</a>)</p><p>Happy coding with Databricks SDK! 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cd5e33cc5f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Data Science Can Helps or Ruin Your Partnership ]]></title>
            <link>https://medium.com/@v.poliakov/how-data-science-can-helps-or-ruin-your-partnership-ad2afb7242e0?source=rss-10ccf113b74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad2afb7242e0</guid>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-quality]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Vladimir Poliakov]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 16:12:50 GMT</pubDate>
            <atom:updated>2023-03-05T23:04:00.393Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>ChatGPT created a new era of AI. Any student can probably create now a data science model without much knowledge. All they have to do is enter the data and the model is ready at the click of a mouse. On the one hand, I think that is good. AI is supposed to optimise the work and help. On the other hand, I fear that people will blindly trust the AI. Unfortunately, it cannot be avoided with the time. And in this context, the critical thinking and the quality of the data play a particularly important role, because the result will look very different.</p><p>In this story, I want to briefly show how even one wrong number can falsify the whole model. As an example, I took the regression analysis, more precisely the Simple Regression from the school program. I choose Simple Regression because it is quite easy to demonstrate the outlier impact with this regression. Therefore, you do not have to start with Deep Learning right away. In many companies, you can do the initial analysis of the data with plain old-school regression analysis, but the Data Quality is very important. As Sample Data I have chosen the activities of “my partnership”.</p><h3>Data Collection</h3><p>As Sample Data I created a small “survey” table with the scoring of the activity from our family (me and my wife) from extremely bad to extremely nice (s. a picture below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*OIhjgNDgiwIPdoLVmGHdVw.png" /></figure><p>The data set was small, seemed to be good and I could put it without any cleaning and preparation into Google Colab Notebook, to calculate the correlation coefficient and to build the Simple Regression.</p><pre># partnership activity with score (score scale is from 1 = extremly bad to 10 = extremly nice)<br>dc_activity_kor = {<br>    &#39;Activity&#39;: [&#39;Walking&#39;, &#39;Jogging&#39;, &#39;Swimming&#39;, &#39;Snorkeling&#39;, &#39;TV Watching&#39;, &#39;Cooking&#39;, &#39;Dancing&#39;, &#39;Traveling&#39;, &#39;Reading&#39;, &#39;Visiting Museums&#39;],<br>    &#39;Me&#39;: [6, 7, 8, 10, 3, 5, 5, 8, 10, 7],<br>    &#39;Partner&#39;: [7, 6, 10, 8, 4, 7, 8, 8, 10, 8]<br>}<br><br>import pandas as pd<br><br># Convert the dictionary to a pandas dataframe<br>df = pd.DataFrame(dc_activity_kor)<br><br># Calculate the correlation between the &quot;Me&quot; and &quot;Partner&quot; columns<br>corr = df[&#39;Me&#39;].corr(df[&#39;Partner&#39;])<br><br># Print the correlation coefficient<br>print(&#39;Correlation coefficient:&#39;, corr)<br><br>from sklearn.linear_model import LinearRegression<br>import matplotlib.pyplot as plt<br><br># Convert the dictionary to a pandas dataframe<br>df = pd.DataFrame(dc_activity_kor)<br><br># Select the &quot;You&quot; column as the independent variable (X)<br>X = df[[&#39;Me&#39;]]<br><br># Select the &quot;Partner&quot; column as the dependent variable (y)<br>y = df[&#39;Partner&#39;]<br><br># Create a LinearRegression object<br>reg = LinearRegression()<br><br># Fit the regression model to the data<br>reg.fit(X, y)<br><br># Print the slope and intercept of the regression line<br>print(&#39;Slope:&#39;, reg.coef_[0])<br>print(&#39;Intercept:&#39;, reg.intercept_)<br><br># Create a scatter plot of the data points<br>plt.scatter(X, y)<br><br># Add the regression line to the plot<br>plt.plot(X, reg.predict(X), color=&#39;red&#39;)<br><br># Add labels and a title to the plot<br>plt.xlabel(&#39;Me&#39;)<br>plt.ylabel(&#39;Partner&#39;)<br>plt.title(&#39;Simple Linear Regression&#39;)<br><br># Display the plot<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*BffTQuoaGPOn3yfLTFUHRw.png" /></figure><p>Quite easy. No any big magic. The correlation coefficient is more than 70%, which means my partnership is good enough. Yes, it is and in the reality, much more than 70% 😁 After that I played a little bit with the data.</p><h3><strong>Limitation and Caveats</strong></h3><p>I changed our “survey” and I put just one outlier into data. Just <strong>one</strong> outlier. A completely normal typing error. After that I executed the Python Code again.</p><pre># partnership activity with score (score scale is from 1 = extremly bad to 10 = extremly nice<br>dc_activity_zerokor = {<br>    &#39;Activity&#39;: [&#39;Walking&#39;, &#39;Jogging&#39;, &#39;Swimming&#39;, &#39;Snorkeling&#39;, &#39;TV Watching&#39;, &#39;Cooking&#39;, &#39;Dancing&#39;, &#39;Traveling&#39;, &#39;Reading&#39;, &#39;Visiting Museums&#39;],<br>    &#39;Me&#39;: [4, 5, 6, 7, 8, 3, 4, 3, 4, 70],<br>    &#39;Partner&#39;: [5, 6, 7, 8, 5, 6, 7, 8, 9, 80]<br>}<br><br>import pandas as pd<br><br># Convert the dictionary to a pandas dataframe<br>df = pd.DataFrame(dc_activity_zerokor)<br><br># Calculate the correlation between the &quot;Me&quot; and &quot;Partner&quot; columns<br>corr = df[&#39;Me&#39;].corr(df[&#39;Partner&#39;])<br><br># Filter out values that are less than 10 and greater than 1<br>df_filtered = df[(df[&#39;Me&#39;] &lt; 10) &amp; (df[&#39;Me&#39;] &gt; 1)]<br><br># Calculate the correlation between the &quot;You&quot; and &quot;Partner&quot; columns<br>corr_filtered = df_filtered[&#39;Me&#39;].corr(df_filtered[&#39;Partner&#39;])<br><br># Print the correlation coefficient<br>print(&#39;Correlation coefficient:&#39;, corr)<br># Print the filtered correlation coefficient<br>print(&#39;Filtered correlation coefficient:&#39;, corr_filtered)<br><br># Print the filtered dataframe<br># print(&#39;Filtered dataframe:\n&#39;, df_filtered)<br><br>from sklearn.linear_model import LinearRegression<br>import matplotlib.pyplot as plt<br><br># Convert the dictionary to a pandas dataframe<br>df = pd.DataFrame(dc_activity_zerokor)<br><br># Select the &quot;You&quot; column as the independent variable (X)<br>X = df[[&#39;Me&#39;]]<br><br># Select the &quot;Partner&quot; column as the dependent variable (y)<br>y = df[&#39;Partner&#39;]<br><br># Create a LinearRegression object<br>reg = LinearRegression()<br><br># Fit the regression model to the data<br>reg.fit(X, y)<br><br># Print the slope and intercept of the regression line<br>print(&#39;Slope:&#39;, reg.coef_[0])<br>print(&#39;Intercept:&#39;, reg.intercept_)<br><br># Create a scatter plot of the data points<br>plt.scatter(X, y)<br><br># Add the regression line to the plot<br>plt.plot(X, reg.predict(X), color=&#39;red&#39;)<br><br># Add labels and a title to the plot<br>plt.xlabel(&#39;Me&#39;)<br>plt.ylabel(&#39;Partner&#39;)<br>plt.title(&#39;Simple Linear Regression&#39;)<br><br># Display the plot<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*iZLpLIL63o1VfvZ17aG9ag.png" /></figure><p>Wow. Bingo. 99% combability with my partner, but in reality, I’m not compatible with my partner 😮😁</p><h3>Conclusion</h3><p>1. Please be careful with “partner survey” 😉 The story was just for fun writing by the (Big) Data Engineer at the weekend<br>2. Linear Regression is not robust to the outliers. Decision Tree or Random Forest are more robust to the outliers<br>3. The Data Cleaning and Data Quality are important. The story was a good sample, why.<br>4. You have not always to create a Data Model by yourself. Of course, you can use the tools. It much easier.<br>5. Please be careful with AI, have a critical thinking and know your Data 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad2afb7242e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyse fitness tracker data with Azure Synapse Analytics]]></title>
            <link>https://medium.com/@v.poliakov/analyse-fitness-tracker-data-with-azure-synapse-analytics-f2cafeef1c91?source=rss-10ccf113b74f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2cafeef1c91</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[azure-synapse-analytics]]></category>
            <category><![CDATA[azure-synapse]]></category>
            <dc:creator><![CDATA[Vladimir Poliakov]]></dc:creator>
            <pubDate>Sun, 29 Jan 2023 22:26:27 GMT</pubDate>
            <atom:updated>2023-01-29T22:26:27.275Z</atom:updated>
            <content:encoded><![CDATA[<p>After reading a story about analysis of the Apple health app data I decided to write my own story 🙂 because I use the Xiaomi Mi 4 fitness tracker.</p><p><strong>What is Azure Synapse Analytics?</strong></p><p>Azure Synapse Analytics (Azure Synapse), like Azure Data Factory (ADF), provides codeless data integration capabilities. Despite many common features, Azure Synapse and ADF have some differences [1]. Shortly these are:<br>- The latest functions are first implemented in Azure Synapse.<br>- ADF functions are no longer supported in Azure Synapse<br>The same data integration engine and environments are integrated in Azure Synapse as in Azure Data Factory, but ADF does not have Spark notebooks, for example. One can say that Azure Synapse combines the best technologies from the world of data warehousing and big data and ADF offers more from the classic DWH in the cloud.</p><p><strong>Use Case from the practice</strong></p><p>The Azure documentation describes in detail different ways to analyse data in Azure Synapse. This article describes a practical example of an Azure Synapse batch ETL pipeline including the serverless Azure Synapse SQL resource models.<br>The data comes from a Xiaomi Mi Fit INTELLI-Band 4 fintesstracker and includes daily activity (number of steps and distance travelled per day) and sleep activity (deep sleep and light sleep). Sure, there are plenty of public data sources on the internet and Mi Fit App also offers some statistics out of the box, but playing with your own data is much more fun for the data engineer 🙂.<br>The data is uploaded as two CSV files to Azure Blob Storage. The Azure Synapse pipeline extracts, transforms and transfers the data into a common CSV file. Afterwards, the data is analysed in the serverless Azure Synapse SQL pool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*4phzNszI2RP-9qAxqsHb8g.jpeg" /></figure><p>The amount of data is quite manageable, which is advantageous for the serverless Azure Synapse SQL pool because it is only charged according to use. The costs that can arise are listed in more detail at the end of the article using a practical example.</p><p><strong>Data provision</strong></p><p>Thanks to the GDPR, fitness tracker owners have the right to export their own data from the device for their own purposes. In the case of Xiaomi Mi Fit INTELLI-Band 4 fintess tracker, this process is not too easy after all and there is not much information on the internet [2].<br>The “short” summary of this action for Xiaomi Mi Fit INTELLI-Band 4 fintess tracker on Android 9, 10 or 11 is:</p><p>- Tap “Profile” at the bottom of the bar in the app.<br>- Scroll down and select “Settings”<br>- In the settings, go to “About” and scroll down again to “Exercise user rights”.<br>- In the “Exercise user rights” section, scroll down again and select “Transfer data”.<br>- In the “Transfer data” section you can finally select all the necessary data and have it sent to an email address.</p><p>The data is first sent from the fitness tracker via the app to the exchange server and within a few minutes you will receive an email with the download link and the password. Under this link is a ZIP file that is protected with the password. After the file has been downloaded and unpacked, the directory structure looks like in a picture below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*KwtLqd93aWeYSrKYHhH5vg.jpeg" /></figure><p>Only the files ACTIVITY.csv and SLEEP.csv are relevant for this article. The structure of this data is quite simple:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*5-2in2Syq1v9CBcUxQwZtA.jpeg" /></figure><p>Both these files are uploaded (for example manually) to Azure Cloud after Azure Synapse Analytics has been prepared.</p><p>The proud Apple Watch owners can access their data more easily. For this, according to [3], they only need three steps and then also get a ZIP file. In this ZIP archive is a large XML file that is still to be parsed for processing in Azure Synapse. However, this article does not cover the preparation of Apple Watch data and focuses only on the CSV data from Xiaomi Mi Fit INTELLI-Band 4 Fintesstracker.</p><p><strong>Preparing Azure Synapse Analytics</strong></p><p>In order to follow all the steps in this article in the Azure Cloud, you need to register in the Azure Cloud Portal and have an active subscription. Registration in the Azure Cloud Portal is free of charge and the Azure offering is available for testing for the first 30 days. After testing, only some components remain more or less free. Azure Synapse is <strong>NOT</strong> one of them, but the use of the included serverless SQL pool is charged according to load and should only cost a few Euros. The whole example as well as the processing of the data is done in the Azure Cloud and no local development environment is needed. Only a good internet connection to the Azure portal is essential.</p><p>Based on Azure best practice, it is strongly recommended to create a separate resource group and storage account for Azure Synapse. In my case I set the Azure region to Germany. An introduction to Azure Synapse can be found here [4] and a step-by-step introduction to creating Azure Synapse can be found here [5]. Even deploying Azure Synapse only takes a few minutes and then the Azure Synapse resource group should look similar to the picture below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zbBnsdkaN01ciVe8OtwMag.png" /></figure><p>Thus, the codeless development environment in Azure Synapse Studio is ready for experimentation. To start Azure Synapse Studio, click in Azure Synapse Workspace and open Azure Synapse Studio.</p><p><strong>Creating Pipeline in Azure Synapse Analytics</strong></p><p>Before creating Pipeline, the ACTIVITY.csv and SLEEP.csv files were uploaded to the same Azure Data Lake storage where the Azure Synapse Workspace is located. From a purely architectural point of view, this should already be stored separately, but for this example, this pattern can be neglected.</p><p>Azure Synapse offers several pipelines and this article introduces the pipeline with Dataflow, which performs the following actions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2M5j8EanwC31_MNnOVX1Q.png" /></figure><p>1. reads in the ACTIVITY.csv and the SLEEP.csv files.<br>2. joins the files together by date of capture<br>3. filters out the superfluous columns (e.g. runDistance)<br>4. calculates totalSleepTime and splits the date into three columns day, month and year<br>5. writes the result into a common ACTIVITY_SLEEP.csv file.</p><p>All these actions are developed in Azure Synapse Studio without code. The general procedure for creating pipelines and dataflows is described step-by-step in [6]. For the dataflow from this example, a Linked Service was created at the beginning to the Azure Data Lake Storage Gen2 account (see above the storage where ACTIVITY.csv and SLEEP.csv files are stored). Then two Input Integration Datasets dsACTIVITY for ACTIVITY.csv and dsSLEEP for SLEEP.csv and an Output Integration Dataset dsOutACTIVITYandSLEEP for ACTIVITY_SLEEP.csv were created.</p><p>To merge the files, Inner-Join was defined as a condition. The selected columns were defined in the Select-Activity. The next step was to build the new columns in the Expression Builder. Finally, the data was sorted in ascending order according to the date of capture and then saved in ACTIVITY_SLEEP.csv. As the data is to be written as one file, the “Single Partition” option must be selected. The same applies to sorting. Otherwise the Current Partitions will be sorted separately and merged into one file randomly. The result is logically an unsorted data set in the CSV file.<br>After the pipeline has been created and published in Azure Synapse, it can also be triggered (menu “Pipelines” Add Trigger Trigger Now). After that, the executions can be seen in the Azure Synapse Monitior. In total, there were 695 sets of sleep data and steps travelled, completely covering only the year 2021. Considering this condition, the analysis was done in the serverless Azure Synapse SQL pool.</p><p><strong>Creating serverless Azure Synapse SQL pool and analysing the data.</strong></p><p>Azure Synapse comes with a built-in serveless SQL pool. The serveless SQL pool has some limitations compared to the dedicated SQL pool (e.g. it only supports the external tables, etc.), but it is only charged by usage, which is much cheaper than the dedicated SQL pool. It is exactly this integrated SQL pool that can also be used for SQL analysis of the fitness tracker data. In principle, it is possible to use the master database from this integrated SQL pool, but the correct way would be to create all custom database objects in a separate non-master database [7] .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9b94YHn0LKXCeZxNtOPr1A.jpeg" /></figure><p>When the new database is ready, you can switch to this database in the editor to create the other user-defined database objects. To access the external table ACTIVITY_SLEEP, you first need Data Source and File Format. If these objects are available and the external table has been created, the SQL query can be executed on this external table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxXYumJ4vWfzwHVwPGpFcw.png" /></figure><p>The results are displayed in tabular form, but in the visual editor of Azure Synapse you can switch to the chart view to build different graphs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p8TW7ou3wdz46ncu9QlAhg.png" /></figure><p>Of course, it would also be possible to join two files ACTIVITY.csv and SLEEP.csv without a pipeline only via SQL “on the fly” in the serverless SQL pool to get a similar result as ACTIVITY_SLEEP.csv. However, the goal of this article was to build a runnable Azure Synapse pipeline. For the other cases, it is important to keep in mind that the unnecessary or frequently executed joins increase the runtimes, increase the demand on Azure resources and as a consequence increase the costs.</p><p>In this use case, it was assumed that daily activity (distance travelled in km) was dependent on sleep. This is basically true, but November contradicts this assumption and a deeper investigation is still needed.</p><p><strong>Costs</strong></p><p>The following costs are incurred for this example:<br>- Cost of Storage Account (storage space) for Azure Synapse Workspace and for holding the fitness tracker data.<br>- Costs for running the pipeline and for using the integrated SQL pool.<br>Since the size of the data is only a few KB and the runtimes of the pipelines and the SQL queries are very short, only a few Euros are incurred for this example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xsmpjOjm2n5S36wuKVr9oQ.png" /></figure><p><strong>Summary and further steps</strong></p><p>The aim of this article was to describe a more or less complete process how to prepare the data in Azure Synapse via pipeline for analysis in the serverless pool. Through a concrete task one gets to know the Azure Synapse Studio and its tools better. Before analysing the data, it was assumed that activity depends on sleep and especially deep sleep. Since 2020 was the year of the lockdown, only the data from 2021 was considered. The assumption regarding the correlation between sleep and activity was basically confirmed by the rough analysis. However, this assumption is not correct for November 2021. The reason was probably particularly rainy bad weather in Nuremberg, which affected activity.</p><p>What comes next? One could refine the analysis and add the weather data, if the GPS coordinates had become known. Or one could build a model using Azure Machine Learning (Azure ML) to check what kind of sleep promotes activity better. In other words what is better short but deep sleep or longer sleep? Or is deep sleep more effective than long sleeps in general?<br>This example shows how quickly and with little effort an Azure Synapse pipeline can be created for a practical use case. In principle, times could analyse this volume of data on a single-board computer (e.g. on the Raspberry Pi) relatively quickly using Python, but Azure Synapse offers a lot out of the box and the cost to experiment in the cloud is really manageable. This makes the learning curve not too steep.</p><p>Of course, there are other things to consider for production use. E.g. the DDL possibilities from the serverless SQL pool are limited and the costs from the dedicated SQL pool are calculated according to a different pricing model. For the other data volumes, the Spark pool will probably make more sense, which is also not free. In addition, security, automatic deployment and much more are also enormously important. And despite these additional issues, it’s worth getting into the cloud or at least researching it.</p><p><strong>Links</strong></p><p>1. Data integration in Azure Synapse Analytics compared to Azure Data Factory — <a href="https://learn.microsoft.com/en-us/azure/synapse-analytics/data-integration/concepts-data-factory-differences">https://docs.microsoft.com/de-de/azure/synapse-analytics/data-integration/concepts-data-factory-differences</a></p><p>2. How to export all Xiaomi Mi Band data — <a href="https://korniichuk.medium.com/export-xiaomi-data-87f7e284b379">https://korniichuk.medium.com/export-xiaomi-data-87f7e284b379</a></p><p>3. How I used Azure databricks, Synapse Analytics, and Azure machine learning to get insights from the Apple health app data — <a href="https://medium.com/@dhangerkapil/how-i-used-azure-databricks-synapse-analytics-and-azure-machine-learning-to-get-insights-from-the-f18fb89ed2e5">https://medium.com/@dhangerkapil/how-i-used-azure-databricks-synapse-analytics-and-azure-machine-learning-to-get-insights-from-the-f18fb89ed2e5</a></p><p>4. Getting started with Azure Synapse Analytics — <a href="https://learn.microsoft.com/en-us/azure/synapse-analytics/get-started">https://docs.microsoft.com/de-de/azure/synapse-analytics/get-started</a></p><p>5. Creating a Synapse workspace — <a href="https://learn.microsoft.com/en-us/azure/synapse-analytics/get-started-create-workspace">https://docs.microsoft.com/de-de/azure/synapse-analytics/get-started-create-workspace</a></p><p>6. Quickstart: Transform data using mapping data flows — <a href="https://learn.microsoft.com/en-us/azure/synapse-analytics/quickstart-data-flow">https://docs.microsoft.com/de-de/azure/synapse-analytics/quickstart-data-flow</a></p><p>7. Analyze data with a serverless SQL pool — <a href="https://learn.microsoft.com/en-us/azure/synapse-analytics/get-started-analyze-sql-on-demand">https://docs.microsoft.com/de-de/azure/synapse-analytics/get-started-analyze-sql-on-demand</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2cafeef1c91" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>