Q01. What is RBAC, which is Role Based Access Control in Snowflake? A01. RBAC is a security model that restricts access to data & resources based on the roles assigned to users. … Read more ›...
Q01. What is RBAC, which is Role Based Access Control in Snowflake? A01. RBAC is a security model that restricts access to data & resources based on the roles assigned to users. … Read more ›...
Prerequisite: Extends 03: Databricks – Spark SCD Type 1. What is SCD Type 1 SCD stands for Slowly Changing Dimension, and it was explained in 10 Data warehouse interview Q&As. … Read more ›...
Prerequisite: … Read more ›...
This extends 15+ SQL scenarios based interview Q&As on Nth value – part 4. This SQL scenarios based interview questions & answers focus on N items per group. These examples were done on MySQL v8.0 at www.db-fiddle.com. … Read more ›...
Q01. What is Azure Active Directory? A01 Azure Active Directory (i.e. AD) is a cloud-based identity and access management (i.e. IAM) solution that provides a centralised, secure, and scalable platform for managing identities, access control, … Read more ›...
Example #13: Explain the concepts
Can you explain the Scala concepts applied in the following code snippets?
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
package com.myapp object Test2 extends App { trait Wrapper[C[_]] { def aFunction[T,R](f: T => R): C[T] => C[R] } implicit object ListWrapper extends Wrapper[List] { //returns a function: so this is a higher order function override def aFunction[T,R](f: T => R): List[T] => List[R] = { l => println("taking T => R & returning List[T] => List[R]") l.map(f) } } // A function that returns an anonymous Object // Anonymous class Test2$$anon$1 AnyRef is like java.lang.Object private implicit def fnGenAnonymousObj[C[_], T](input: C[T]) = new { // or new AnyRef or new Object //takes a function as an arg: So, this is a higher order function def anotherFunction[R](f: T => R)(implicit wrap: Wrapper[C]): C[R] = { println("In here first.......") val aClosure: C[T] => C[R] = wrap.aFunction(f) // C[T] => C[R] val result: C[R] = aClosure(input) // pass the list to the closure result } } //val result = fnGenAnonymousObj(List(1, 2, 3)).anotherFunction {x => x + 1}(ListWrapper) // without implicits val result = List(1, 2, 3).anotherFunction {x => x + 1} println(result) //val result2 = fnGenAnonymousObj(List("Java", "Scala")).anotherFunction {x => x.length}(ListWrapper) // without implicits val result2 = List("Java", "Scala").anotherFunction {x => x.length} // with implicits println(result2) } |
Output:
|
1 2 3 4 5 6 7 8 |
In here first....... taking T => R & returning List[T] => List[R] List(2, 3, 4) In here first....... taking T => R & returning List[T] => List[R] List(4, 5) |
1. Higher Order Functions: “Line 12” is a higher order function as the function not only takes a function as an argument i.e.
…
Q1. How will you convert parquet data to data lake in Databricks? A1. A parquet data will have a list of *.snappy.parquet files under each partition like year=2023, month=02, day-25, etc.
|
1 2 3 4 5 |
%sql CONVERT TO DELTA parquet.`abfss://mycontainer@mystorageaccount.dfs.core.windows.net/user_detail` PARTITIONED BY (year STRING, month STRING, day STRING) |
|
1 2 3 4 5 6 |
%python from delta.tables import * deltaTable = DeltaTable.convertToDelta(spark, "parquet.`abfss://mycontainer@mystorageaccount.dfs.core.windows.net/user_detail`", "year STRING, month STRING, day STRING") |
Q2. … Read more ›...
Q1. What is an ETL process? A1. ETL is a architectural style, and it stands for Extract, Transform and Load. Extract does the process of reading data from an input data source like file, database, etc. … Read more ›...
Q1. How do you produce & interpret Linear Regression output? A1. Scatter plots can only detect obvious relationships between variables by looking at the graph, but we can use statistics to comment about the variable relationships as outlined below. The link 11A: Databricks – Spark ML – Pandas Dataframe &...
This extends Pyspark with schema & a simple join of two data frames example.
Q08: How would you read csv data into a spark Dataframe?
A08: Here is the tutorial step by step that reads employee.csv file into the Dataframe.
…
Q. How would you go about debugging Python code? A. Firstly, import pdb
|
1 2 |
import pdb |
Secondly, use “pdb.set_trace()” where ever you want the execution to pause as shown below with “addition.py” file. … Read more ›...
Q13. What are the different approaches in Scala to solve the following task?
Given numbers 1 to 6, and you need to extract out the odd numbers and double them, and finally print the result.
A13. There are 3 ways to solve the problem.
…
Java has idioms like Try-Catch-Finally, Scala has idioms like 1) “Option-Some-None”, 2) Either-Left-Right 3) Try-Success-Failure. Q27. How does Scala try to solve the problem of getting rid of null values & the “NullPointerException”? A27. Scala provides its own type for representing optional values with “Option[A]”, … Read more ›...
I have a good news, I got job offer. I like to share with you from my bottom of my heart feeling thankful to you.