<?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 haner on Medium]]></title>
        <description><![CDATA[Stories by haner on Medium]]></description>
        <link>https://medium.com/@haner11?source=rss-5210f853e73------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*N__1u0f5OEjDWXhhrq1WWg.png</url>
            <title>Stories by haner on Medium</title>
            <link>https://medium.com/@haner11?source=rss-5210f853e73------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:14:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@haner11/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[Connecting Databricks with Microsoft SharePoint]]></title>
            <link>https://medium.com/@haner11/connecting-databricks-with-microsoft-sharepoint-4db9d5b5dcbb?source=rss-5210f853e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/4db9d5b5dcbb</guid>
            <category><![CDATA[databricks-widget]]></category>
            <category><![CDATA[scopes]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[sharepoint]]></category>
            <dc:creator><![CDATA[haner]]></dc:creator>
            <pubDate>Sun, 23 Apr 2023 16:20:49 GMT</pubDate>
            <atom:updated>2023-04-23T16:29:15.056Z</atom:updated>
            <content:encoded><![CDATA[<p>It shouldn’t be difficult to share data from Databricks on a SharePoint page. After establishing a connection with SharePoint, we can upload any file, such as a CSV file, to a desired page that we have permission to access.</p><p>First, we need to download the <strong>Office365-REST-Python-Client</strong> in our Databricks notebook page to be able to establish a connection with Microsoft SharePoint.</p><pre>%pip install Office365-REST-Python-Client</pre><p>After the upload is completed, the interpreter needs to be restarted, so we perform this download process in the notebook first.</p><p>How can we upload a CSV file to a SharePoint page regularly every month? Let’s continue from here…</p><p>First, let’s extract data from a table in Unity Catalog and save it to Databricks Filestore. Also, let’s extract the current date from the dataset and add it to the file name. This way, we can easily see which month the CSV files uploaded to SharePoint belong to.</p><pre># Get the latest date<br>sqlCmd = ‘’’<br>SELECT CONCAT(<br>  LPAD(CAST(YEAR(MAX(Date)) AS STRING), 4, ‘0’),<br>  LPAD(CAST(MONTH(MAX(Date)) AS STRING), 2, ’0’)<br>) AS date_max<br>FROM<br>  gold_dev.lineagedemo.menu<br>‘’’<br><br>sdf_date_max = spark.sql(sqlCmd)<br>sdf_date_max = sdf_date_max.toPandas()<br>sdf_date_max = sdf_date_max[‘date_max’][0]<br><br># Print the current date as info<br>print(f’ Actual Date: {sdf_date_max}’)<br><br>actual_date = sdf_date_max[0:4] + ‘-‘ + sdf_date_max[4:6] + ‘-’ + ‘01’<br><br># Print the start date of the dataset as info<br>print(f’ Dataset starts from this date: {actual_date}’)<br><br># Save the current date as an SQL variable<br>spark.conf.set(‘actual_date’, actual_date)</pre><p>Let’s filter the dataset with <strong>“actual_date”</strong> that we have set as the current date and save it as a Spark dataframe.</p><pre># Filter dataset with SQL variable (actual_date) that we just created<br>sqlCmd = ‘’’<br>SELECT<br>  *<br>FROM<br>  gold_dev.lineagedemo.menu<br>WHERE<br>  Date &gt;= “${actual_date}”<br>‘’’<br><br># Save the dataset as spark dataframe<br>sdf = spark.sql(sqlCmd)</pre><p>At this stage, we will determine the file name and path to be saved in Databricks Filestore. If the file has been saved before, we will display a warning and not try to save the same file again.</p><pre># Download the datetime module<br>from datetime import datetime.<br><br># Define the path and file names<br>path_spark = &#39;dbfs:/lineagedemo/monthly_files&#39;<br>file_name = &#39;demo&#39; + sdf_date_max + &#39;.csv&#39;<br>file_spark = path_spark + &#39;/&#39; + file_name<br><br># Check the path if the file already saved<br>files_path = dbutils.fs.ls(path_spark) # Note: spark.databricks.service.client should be enabled.<br>files_path_list = []<br>for i in range(0, len(files_path)):<br>               files_path_list.append(files_path[i][0])<br>if file_spark+&quot;/&quot; in files_path_list:<br>    m_time = dbutils.fs.ls(file_spark)[0][-1]/1000<br>    m_time = datetime.fromtimestamp(m_time).strftime(&#39;%Y-%m-%d %H:%M&#39;)<br>    print(f&#39;Hint: {file_name} was already in {m_time} modified.&#39;)<br>else:<br>    sdf.coalesce(1).write.format(&#39;com.databricks.spark.csv&#39;) \<br>        .option(&#39;header&#39;, &#39;False&#39;) \<br>        .option(&#39;encoding&#39;, &#39;utf-8&#39;) \<br>        .option(&#39;delimiter&#39;, &#39;;&#39;) \<br>        .save(file_spark)<br><br># Change the file name for sharepoint<br>files = dbutils.fs.ls(file_spark)<br>csv_file = [x.path for x in files if x.path.endswith(&quot;.csv&quot;)][0]<br>csv_file = &#39;/dbfs/&#39; + csv_file[6:]<br><br>path = &#39;/dbfs/lineagedemo/monthly_files&#39;<br>file = path + &#39;/&#39; + file_name<br><br># Print to see if we upload the correct file<br>print(f&#39;File: {file_name} will be uploaded to sharepoint.&#39;)</pre><h3>Secret Scope</h3><p>During any connection instead of directly writing our personal information into the notebook, we can request them in a hidden way. These secret credentials are stored in an encrypted database managed by Databricks.</p><p>We can use <strong>dbutils.secret</strong> to set up the username and password we will use for the Sharepoint connection. First, we need to create a Databricks <strong>secret</strong> <strong>scope</strong>. <br>It is worth noting that all users in the workspace have access to these created secrets. For more detailed information, you can refer to the links provided in the sources.</p><p>Let’s create 2 secret scopes, one for the username and one for the password.</p><pre># databricks secrets create-scope --scope &lt;scope-name&gt;<br><br>databricks secrets create-scope --scope &lt;username&gt;<br>databricks secrets create-scope --scope &lt;password&gt;</pre><p>We can encrypt our secret information (“<strong>username</strong>” and “<strong>password</strong>”) using the put command for the created scopes, which will be our <strong>username</strong> and <strong>password</strong>.</p><pre># databricks secrets put --scope &lt;scope-name&gt; --key &lt;key-name&gt;<br><br>databricks secrets put --scope &lt;username&gt; --key &lt;user@company.com&gt;<br>databricks secrets put --scope &lt;password&gt; --key &lt;user1234&gt;</pre><p>To delete the <strong>scope</strong> and <strong>secrets</strong> we created, we can use the following commands:</p><pre># databricks secrets delete --scope &lt;scope-name&gt;<br># databricks secrets delete --scope &lt;scope-name&gt; --key &lt;key-name&gt;</pre><h3>Databricks widgets</h3><p>As a second method for providing user information, we can also use <strong>widgets</strong> here.<br>However, it’s unfortunately not possible to make automatic updates with <strong>widgets</strong>, because the user informations must be entered manually.<br>Let’s define 2 <strong>widgets</strong> for the username and password.</p><pre>dbutils.widgets.text(name=&#39;widget_user&#39;, defaultValue=&#39;&#39;, label=&#39;User&#39;)<br>dbutils.widgets.text(name=&#39;widget_pw&#39;, defaultValue=&#39;&#39;, label=&#39;Password&#39;)</pre><p>After creating the widgets, they will appear at the top of the notebook page under the Widgets section. For example, we can enter our email address in the <strong>User</strong> section and our password in the <strong>Password</strong> section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*ITmcwG-hY-pwyQnga0pztQ.png" /></figure><p>When making the connection, we can use <strong>widget_user</strong> and <strong>widget_pw </strong>to provide our informations.</p><pre>user = dbutils.widgets.get(&quot;widget_user&quot;)<br>password = dbutils.widgets.get(&quot;widget_pw&quot;)</pre><p>After completing the operations, we can remove the widgets from the notebook page.</p><pre>dbutils.widgets.remove(&quot;widget_user&quot;)<br>dbutils.widgets.remove(&quot;widget_pw&quot;)<br><br># dbutils.widgets.removeAll()  --for removing all widgets</pre><h3>Sharepoint Connection</h3><p>We can start our Sharepoint connection.<br>Here, what we will do is:<br>- determine the Sharepoint page where we will upload files<br>- provide user information inputs<br>- establish the Sharepoint connection<br>- upload the file<br><em>Note: The user who will make this connection must have permission to make changes also on the SharePoint page.</em></p><pre># Import the libraries<br>import os<br>from office365.runtime.auth.user_credential import UserCredential<br>from office365.sharepoint.client_context import ClientContext<br>from office365.sharepoint.files.file import File<br><br># Sharepoint webpage path<br>sharepoint_site = &#39;demo&#39;<br>sharepoint_folder = &#39;lineagedemo/prices&#39;<br><br># Get user informations<br>username = dbutils.secrets.get(&quot;username&quot;)<br>password = dbutils.secrets.get(&quot;password&quot;)<br>&#39;&#39;&#39;<br>If we want to do it with widgets:<br>username = dbutils.widgets.get(&quot;widget_user&quot;)<br>password = dbutils.widgets.get(&quot;widget_pw&quot;)<br>&#39;&#39;&#39;<br><br># Set environment variables<br>SITE_URL = f&quot;https://company.sharepoint.com/sites/{sharepoint_site}&quot;<br>RELATIVE_URL = f&quot;/sites/{sharepoint_site}/{sharepoint_folder}&quot;<br><br># Connect to sharepoint<br>ctx = ClientContext(SITE_URL).with_credentials(UserCredential(username, password))<br>web = ctx.web.get().execute_query()<br>print(&quot;Web title: {0}&quot;.format(web.properties[&#39;Title&#39;]))<br><br># Generate csv file and upload to the sharepoint page<br>with open(csv_file, &#39;rb&#39;) as content_file:<br>    file_content = content_file.read()<br><br>name = os.path.basename(file)<br>ctx.web.get_folder_by_server_relative_url(https://medium.com/sharepoint_folder).upload_file(name, file_content).execute_query()<br><br>&#39;&#39;&#39;<br>If we want to rename the folder:<br>ctx.web.get_folder_by_server_relative_url(https://medium.com/sharepoint_folder).rename(&quot;prices_v2&quot;).execute_query()<br>&#39;&#39;&#39;</pre><p>If you enable the automatic update of the databricks notebook you created through a <strong>databricks</strong> <strong>Workflows</strong>, for example on a monthly basis update, you can upload a file like “monthly_prices”, as we did in this example, to the SharePoint page every month.</p><p><em>Sources:<br></em><a href="https://github.com/vgrem/Office365-REST-Python-Client"><em>https://github.com/vgrem/Office365-REST-Python-Client</em><br></a><a href="https://docs.databricks.com/security/secrets/secret-scopes.html"><em>https://docs.databricks.com/security/secrets/secret-scopes.html</em></a><em><br></em><a href="https://docs.databricks.com/notebooks/widgets.html"><em>https://docs.databricks.com/notebooks/widgets.html</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4db9d5b5dcbb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Capture and display data lineage with Unity Catalog]]></title>
            <link>https://medium.com/@haner11/capture-and-display-data-lineage-with-unity-catalog-e915ceeef37c?source=rss-5210f853e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/e915ceeef37c</guid>
            <category><![CDATA[unity-catalog]]></category>
            <category><![CDATA[data-lineage]]></category>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[haner]]></dc:creator>
            <pubDate>Sun, 16 Apr 2023 09:45:06 GMT</pubDate>
            <atom:updated>2023-04-16T09:45:06.430Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, Databricks introduced a feature called “lineage” for displaying data lineage. This feature, which shows the relationships between data sets stored or saved using Unity Catalog, will be very helpful in understanding where the data came from or how it was created. This feature also displays relationships at the column level and will be particularly useful for those working in the data engineering department to make their jobs easier.</p><p><strong>Requirements:<br></strong>· Unity Catalog must be enabled and the data must be stored here.<br>· Queries must be at the Spark DataFrame or Databricks SQL level. Unfortunately, the data lineage of data tables converted to Python DataFrame cannot be taken.<br>· To be able to view the data lineage of any dataset, the user must have the necessary permissions (SELECT privilege).<br>· Users must have access to dataLineage.<br>· When creating any new dataset to show its lineage, these relationships must be specified in the query section. Data lineage cannot be captured for directly written data (such as data sets saved from the Spark data set to a Python DataFrame).</p><p><strong>Limitations: </strong><br>· Supported on Databricks Runtime 11.2 or higher versions.<br>· When data is written directly to files in cloud storage, data lineage cannot be captured even if a table is defined at the cloud storage location. For example, data sets saved with the “spark.write.save” command cannot help in creating data lineage.<br>· The metadata of the created data tables is stored for a period of 30 days. Therefore, if 30 days have passed since a query, this data lineage cannot be displayed.<br>· Requests executed with the Jobs API cannot be used when displaying data lineage. During execution, the data lineage or metadata is captured, but the execution connection cannot be captured.<br>· dataLineage cannot be used for the Delta Live Tables pipeline.<br>· Data lineage is captured at the column level with the correct queries, but there may be some inconsistencies in column relationships in some cases. · If any table is renamed, data lineage cannot be captured for the renamed table.</p><p>Let’s reinforce what has been explained with a simple example:</p><p>We are in the gold_dev catalog as a catalog, and we create a database called <strong>“lineagedemo”</strong> for ourselves at the very beginning.</p><pre>%sql<br><br>CREATE DATABASE IF NOT EXISTS<br>  gold_dev.lineagedemo</pre><p>In the first step, we will create a data table called <strong>“menu” </strong>using an SQL query. Then, in the same SQL query, we will create a data table called <strong>“dinner” </strong>using the data from the <strong>“menu”</strong> data table.</p><pre>%sql<br><br>CREATE TABLE IF NOT EXISTS<br>  gold_dev.lineagedemo.menu (<br>    recipe_id INT,<br>    app string,<br>    main string,<br>    dessert string,<br>  );<br><br>INSERT INTO gold_dev.lineagedemo.menu<br>   (recipe_id, app, main, dessert)<br>VALUES<br>  (1, &quot;Ceviche&quot;, &quot;Tacos&quot;, &quot;Flan&quot;),<br>  (2, &quot;Tomato Soup&quot;, &quot;Souffle&quot;, &quot;Creme Brulee&quot;),<br>  (3, &quot;Chips&quot;, &quot;Grilled Cheese&quot;, &quot;Cheesecake&quot;);<br><br>CREATE TABLE<br>  fold_dev.lineagedemo.dinner<br>AS SELECT<br>  recipe_id, concat(app, &quot; + &quot;, main, &quot; + &quot;, dessert)<br>AS<br>  full_menu<br>FROM<br>  gold_dev.lineagedemo.menu</pre><p>Let’s quickly take a look at the columns in the tables…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*hR5281m_epQ8-pJ4.png" /><figcaption>1) The “dinner” data table that we created first</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*7loQDVdGEpHY8BRX.png" /><figcaption>2) The second data table “menu” that we created based on the “dinner” table</figcaption></figure><p>Let’s take a look at the relationship between the two tables we created and other options under the lineage tab:</p><p>If we examine the <strong>“menu”</strong> data table in the lineage tab, we see that the first data table we created, <strong>“dinner” </strong>appears downstream. There is no data upstream because we did not create any new data tables using the <strong>“menu”</strong> table.</p><p>In addition, Notebook, Workflow, and Dashboard work related to the selected data table can be accessed in the menu on the left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*RYK_SVULmumHS6u8.png" /><figcaption>3) View of the “menu” table under the Lineage tab</figcaption></figure><p>As mentioned in the Requirements section, we need to grant the necessary <strong>SELECT</strong> privilege access to the user from the Permissions tab. In this example, we can grant <strong>SELECT</strong> permissions to the database and all tables under it in this way. <strong>MODIFY</strong> provides access to make changes to the database or tables.</p><pre>%sql<br><br>GRANT USAGE, CREATE on SCHEMA gold_dev.lineagedemo<br>to &#39;KeyUser_data_owner&#39;</pre><pre>%sql<br><br>GRANT SELECT ON ALL TABLES IN SCHEMA SCHEMA gold_dev.lineagedemo<br>to &#39;KeyUser_data_owner&#39;</pre><pre>%sql<br><br>GRANT SELECT ON ALL TABLES IN SCHEMA SCHEMA gold_dev.lineagedemo<br>to &#39;user@company.com&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*OMLwrzL0cuaifUmj.png" /><figcaption>4) Here is the view of the permissions tab of the “menu” table</figcaption></figure><p>We can access the data lineage schema with <strong>See Lineage Graph</strong> (see Image 3). As we can also see on a column-level from the<strong> “dinner” </strong>table, the <strong>“full_menu”</strong> column is created from the other three columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*nUP8cMHxAUdm-G9f.png" /><figcaption>5) Data lineage of the “menu” data table</figcaption></figure><p>Let’s expand the data source schema by adding more data tables and take a look at the lineage graph again. This time, let’s use a spark DataFrame instead of SQL. Create a new data table named <strong>“price”</strong> with randomly generated prices.<br>Also, create a new dataset named <strong>“dinner_price”</strong> that shows the prices of the <strong>“dinner”</strong> data table.</p><pre>from pyspark.sql.functions import rand, round<br>df = spark.range(3)<br>      .withColumn(&quot;price&quot;, round(10*rand(seed=42),2))<br>      .withColumnRenamed(&quot;id&quot;, &quot;recipe_id&quot;)<br><br>df.write.mode(&quot;overwrite&quot;).saveAsTable(&quot;gold_dev.lineagedemo.price&quot;)<br><br>dinner = spark.read.table(&quot;gold_dev.lineagedemo.dinner&quot;)<br>price = spark.read.table(&quot;gold_dev.lineagedemo.price&quot;)<br><br>dinner_price = dinner.join(price, on=&quot;recipe_id&quot;)<br>dinner_price.write.mode(&quot;overwrite&quot;).saveAsTable(&quot;gold_dev.lineagedemo.dinner_price&quot;)</pre><p>If we look at our lineage graph again, we can see the new data tables we created and their connections (including at the column level).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*keBioB_cMa9JUtOm.png" /><figcaption>6) Data lineage of the “menu” data table</figcaption></figure><p><em>Source: </em><a href="https://docs.databricks.com/data-governance/unity-catalog/data-lineage.html"><em>https://docs.databricks.com/data-governance/unity-catalog/data-lineage.html</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e915ceeef37c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity Catalog ile veri kökenini (data lineage) yakalama ve görüntüleme]]></title>
            <link>https://medium.com/@haner11/unity-catalog-ile-veri-k%C3%B6kenini-data-lineage-yakalama-ve-g%C3%B6r%C3%BCnt%C3%BCleme-6c2da395b17f?source=rss-5210f853e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c2da395b17f</guid>
            <category><![CDATA[data-lineage]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[haner]]></dc:creator>
            <pubDate>Mon, 26 Dec 2022 11:53:25 GMT</pubDate>
            <atom:updated>2022-12-26T11:54:30.447Z</atom:updated>
            <content:encoded><![CDATA[<p>Geçtiğimiz günlerde databricks tarafında lineage adı altında bir veri kökeni görüntüleme özelliği geldi. Unity catalog kullanılarak kaydedilen veya depolanan veri setlerinin birbirleri arasındaki ilişkileri gösteren bu özellik, verinin nereden geldiğini veya nasıl oluşturulduğunu anlamada bizlere çok yardımcı olacaktır. Sütun bazında dahi ilişkileri gösteren bu özellik en çok da data engineering bölümünde çalışanların işini kolaylaştıracaktır.</p><h4><strong>Gereklilikler</strong></h4><p><strong>·</strong> Unity catalog etkinlestirilmiş olmalıdır ve veriler burada depolanmış olmalıdır.<br><strong>·</strong> Sorgular, Spark DataFrame veya Databricks SQL düzeyinde olmalıdır. Python DataFrame’e çevirilen veri tablolarının veri kökeni malesef alınamamaktadır.<br><strong>·</strong> Herhangi bir veri setinin veri kökenine bakabilmek için o kullanıcının gerekli izinlere sahip olması gereklidir (SELECT privilege).<br><strong>·</strong> Kullanıcıların dataLineage erişimine sahip olması gereklidir.<br><strong>·</strong> Veri kökenini gösterebilmek için herhangi bir yeni veri seti oluşturulurken bu ilişkiler sorgu kısmında belirtilmelidir. Doğrudan yazılan veriler için (yukarıda belirtilen spark veri setinden python DataFrame’e kaydedilen veri setleri gibi) veri kökeni yakalanamaz.</p><h4><strong>Sınırlamalar</strong></h4><p><strong>·</strong> Databricks Runtime 11.2 veya daha üzeri sürümlerde desteklenir.<br><strong>·</strong> Veriler doğrudan bulut depolama alanındaki dosyalara yazıldığında, bulut depolama konumunda bir tablo tanımlanmış olsa bile veri kökeni yakalanamaz. Örneğin “spark.write.save” komutu ile kaydedilen veri setleri, veri kökeni oluşturmada yardımcı olamaz.<br><strong>·</strong> Oluşturulan veri tablolarının metadataları 30 gün süresince saklanır. Bu yüzden, eğer bir sorgu üzerinden 30 gün geçmiş ise bu veri kökeni de gösterilemez.<br><strong>·</strong> Jobs API ile çalıştırılan istekler veri kökeni görüntülenirken kullanılamaz. Çalıştırma sırasında veri kökeni yani metadata yakalanır ancak çalıştırma bağlantısı yakalanamaz.<br><strong>·</strong> dataLineage Delta Live Tables pipeline için kullanılamaz.<br><strong>·</strong> Veri kökeni doğru sorgular ile sütun düzeyinde yakalanır ancak bazı durumlarda sütun ilişkilerinde aksaklıklar da olabilir.<br><strong>·</strong> Herhangi bir tablo yeniden adlandırılırsa, yeniden adlandırılan tablo için veri kökeni yakalanamaz.</p><p>Basit bir örnekle bu anlatılanları pekiştirelim:</p><p>Katalog olarak gold_dev kataloğundayız ve kendimize en başta <strong>“lineagedemo“</strong> adında bir database oluşturuyoruz.</p><pre>%sql<br><br>CREATE DATABASE IF NOT EXISTS<br>  gold_dev.lineagedemo</pre><p>Ilk etapta SQL sorgusu ile <strong>“menu“</strong> adında bir veri tablosu oluşturacağız. Daha sonra aynı SQL sorgusunda <strong>“dinner“</strong> adında bir veri tablosunu <strong>“menu“</strong> veri tablosundaki verilerden yararlanarak oluşturacağız.</p><pre>%sql<br><br>CREATE TABLE IF NOT EXISTS<br>  gold_dev.lineagedemo.menu (<br>    recipe_id INT,<br>    app string,<br>    main string,<br>    dessert string,<br>  );<br><br>INSERT INTO gold_dev.lineagedemo.menu<br>   (recipe_id, app, main, dessert)<br>VALUES<br>  (1, &quot;Ceviche&quot;, &quot;Tacos&quot;, &quot;Flan&quot;),<br>  (2, &quot;Tomato Soup&quot;, &quot;Souffle&quot;, &quot;Creme Brulee&quot;),<br>  (3, &quot;Chips&quot;, &quot;Grilled Cheese&quot;, &quot;Cheesecake&quot;);<br><br>CREATE TABLE<br>  fold_dev.lineagedemo.dinner<br>AS SELECT<br>  recipe_id, concat(app, &quot; + &quot;, main, &quot; + &quot;, dessert)<br>AS<br>  full_menu<br>FROM<br>  gold_dev.lineagedemo.menu</pre><p>Tablolardaki sütunlara hızlıca bir göz atalım…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*yQBpyDyTk7OZJeyyf4mqDw.png" /><figcaption><em>1) Ilk olu</em>ş<em>turdu</em>ğ<em>umuz “dinner“ veri tablosu</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*ygXGm3SByhjIYAPDqgP0YQ.png" /><figcaption><em>2) “dinner“ tablosu üzerinden olu</em>ş<em>turdu</em>ğ<em>umuz ikinci veri tablosu “menu“</em></figcaption></figure><p>Oluşturduğumuz iki veri tablosununun birbileri arasındaki ilişkiye ve lineage sekmesi altındaki diğer seçeneklere bir göz atalım:</p><p><strong>“menu”</strong> veri tablosunu lineage sekmesinde inceleyecek olursak, Downstream’de karşımıza ilk oluşturduğumuz <strong>“dinner”</strong> veri tablosu çıkıyor. Upstream’de ise herhangi bir veri yok çünkü <strong>“menu”</strong> tablosunu kullanarak herhangi yeni bir veri tablosu oluşturmadık.</p><p>Ayrıca sol taraftaki menüde seçilen veri tablosuna ait Notebook, Workflow ve Dashboard çalışmalarına da erişilebilmektedir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*FuVClufRqudL2mZSELI0zg.png" /><figcaption>3) “menu” veri tablosunun Lineage sekmesi altındaki görünümü</figcaption></figure><p>Gereklilikler bölümünde belirtildiği gibi Permissions sekmesinden gerekli olan <strong>SELECT</strong> privilege erişimini kullanıcıya vermemiz gerekmektedir.<br>Bu örnekte database ve database altında bulunan tüm tablolara bu şekilde <strong>SELECT</strong> izinlerini verebiliriz.<br><strong>MODIFY</strong> ise database veya tablolarda değişiklikler yapılmasına erişim sağlar.</p><pre>%sql<br><br>GRANT USAGE, CREATE on SCHEMA gold_dev.lineagedemo<br>to &#39;KeyUser_data_owner&#39;</pre><pre>%sql<br><br>GRANT SELECT ON ALL TABLES IN SCHEMA SCHEMA gold_dev.lineagedemo<br>to &#39;KeyUser_data_owner&#39;</pre><pre>%sql<br><br>GRANT SELECT ON ALL TABLES IN SCHEMA SCHEMA gold_dev.lineagedemo<br>to &#39;user@company.com&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*c7niU27tKINNW1IBpOSlJw.png" /><figcaption>4) “menu” veri tablosunun izinler sekmesinin görünümü</figcaption></figure><p><strong>See Lineage Graph</strong> (bkz. 3. Resim) ile veri kökeni şemasına erişebiliriz. <strong>“dinner“</strong> veri tablosundan sütun bazında da görebildiğimiz gibi <strong>“full_menu“</strong> sütunu diğer üç sütundan oluşturulmuştur.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*Bhj-L9ubqtAgO61xFl035w.png" /><figcaption>5) “menu” veri tablosunun veri kökeni</figcaption></figure><p>Veri tablolarını arttırarak veri kökeni şemasına tekrar bakalım.<br>Bu defa SQL yerine spark DataFrame ile ilerleyelim.<br><strong>“price“</strong> isimli yeni bir veri tablosunu fiyatları random olacak şekilde oluşturalım.<br>Bir de <strong>“dinner_price“</strong> adında <strong>“dinner“</strong> isimli veri tablosunun fiyatlarını gösteren yeni bir veri seti oluşturalım.</p><pre>from pyspark.sql.functions import rand, round<br>df = spark.range(3)<br>      .withColumn(&quot;price&quot;, round(10*rand(seed=42),2))<br>      .withColumnRenamed(&quot;id&quot;, &quot;recipe_id&quot;)<br><br>df.write.mode(&quot;overwrite&quot;).saveAsTable(&quot;gold_dev.lineagedemo.price&quot;)<br><br>dinner = spark.read.table(&quot;gold_dev.lineagedemo.dinner&quot;)<br>price = spark.read.table(&quot;gold_dev.lineagedemo.price&quot;)<br><br>dinner_price = dinner.join(price, on=&quot;recipe_id&quot;)<br>dinner_price.write.mode(&quot;overwrite&quot;).saveAsTable(&quot;gold_dev.lineagedemo.dinner_price&quot;)</pre><p>Veri kökeni şemamiza tekrardan bakacak olursak yeni oluşturduğumuz veri tablolarını ve bağlantılarını (sütun bazında da) görebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*ED4dMdm-m9cU4wRXCRYWwQ.png" /><figcaption>6) “menu” veri tablosunun veri kökeni</figcaption></figure><blockquote>Kaynak: <a href="https://docs.databricks.com/data-governance/unity-catalog/data-lineage.html">https://docs.databricks.com/data-governance/unity-catalog/data-lineage.html</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c2da395b17f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snail Date App via Snail Trail from Chambers]]></title>
            <link>https://medium.com/@haner11/snail-date-app-via-snail-trail-from-chambers-690a2aee89bc?source=rss-5210f853e73------2</link>
            <guid isPermaLink="false">https://medium.com/p/690a2aee89bc</guid>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[snail-trail]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[avalanche]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[haner]]></dc:creator>
            <pubDate>Thu, 05 May 2022 20:00:48 GMT</pubDate>
            <atom:updated>2022-05-05T22:42:33.177Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Snail Date App:</strong> <a href="https://share.streamlit.io/chamberss2022/snail-app/main/snail-app.py">https://share.streamlit.io/chamberss2022/snail-app/main/snail-app.py</a></p><p>Snail Trail is a racing &amp; breeding game exclusively on <a href="https://medium.com/u/f7c9f4ea738f">Avalanche</a> Network. What are they doing? Explained here very well <a href="https://docs.snailtrail.art/"><strong>https://docs.snailtrail.art/</strong></a> The game will be released today at 7pm EST, you can reach from this link <a href="https://www.snailtrail.art/"><strong>https://www.snailtrail.art/</strong></a><strong> </strong><br>How the racing works is not clear but we have some clue for the breeding. I am gonna try explain basically how the breeding works. For more information I highly recommend you to check <a href="https://docs.snailtrail.art/">whitepaper</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vuw20IjFNfxhAQ0C" /><figcaption>Snail Trail</figcaption></figure><h4>What is this breeding?</h4><p>So we have Snails and the population is now 7400!<br>We’ve got one Snail, so what to do? For the breeding of course we want to find the best partner snail like in real world :)<br>There are 5 families; Atlantis, Agate, Milk, Helix and Garden. “Atlantis” is the rarest family and “Garden” the most common.</p><p><strong>Okay enough! How does it work, just say it!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nvtm2XGc3_lJSOjO.png" /><figcaption>DNA crossing</figcaption></figure><p>So let’s say there are two snails. P1 is “Garden” and P2 is “Atlantis”. Every snails have 20 gens (X, A, M, H, G). Above there is an example of genetic sequence of five possible offspring out of the 1000s possible ones that this couple can produce. As you see you can get one (C1, C2, C3, C4 or C5) from all of families but obviously the possibilities are different.</p><h4><strong>So, what does the Snail Date App do?</strong></h4><p>Basically you just need to enter your gene of snail and with which family you want to breeding. For example: you have P1 (Garden) and you want to breed with P2 (Atlantis), then choose “Atlantis”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dxC-drgcZZBswROIjH_4TA.png" /></figure><p>At last you can select a target family as a new snail, let’s say it “Milk”.<br>With the list you get, you can find partner snails (possible P2s) that will give you the highest probabilities from the selected target family.</p><h4>So what? What are you doing actually?</h4><p>Again, there are 7400 snails!<br>In our breeding experiments, there is not much difference in the results of producing 1.000 and 10.000 possible new snails. That’s why we are going with 1.000 but because of looooooong waiting time we reduced that number.</p><p>We generated probable new snails from breeding all partner snails from the selected family with the P1 snail (it is the snail that you write the gene).<br>From the possible snails, we check the rates of families and sort it by target family, that you select.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3UQKz_V2LtbtsiclzHGAg.png" /></figure><p>For the high accurate result you can contact with our team.</p><h4>I read the whitepaper, there is more!</h4><p>Yesss. Actually we can also show which purities are possible. Oh oh oh wait purity???<br>There is more in this game. Also crossing of classes (now, all of snails are genesis). But for the beginning it is enough to breeding our SNAILSSS!<br>Just try the app and don’t hesitate to contact with us.</p><p><strong><em>Snail Date App<br></em></strong><a href="https://share.streamlit.io/chamberss2022/snail-app/main/snail-app.py"><em>https://share.streamlit.io/chamberss2022/snail-app/main/snail-app.py</em></a></p><p><strong><em>Chambers | Contact<br></em></strong><em>Github: </em><a href="https://github.com/chamberss2022"><em>https://github.com/chamberss2022</em></a><em><br>Linkedin: </em><a href="https://www.linkedin.com/company/chamberss-group/"><em>https://www.linkedin.com/company/chamberss-group/</em></a><em><br>E-Mail: chamberss2022@gmail.com</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=690a2aee89bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>