Code snippets and tips for various programming languages/frameworks. All code examples are under MIT or Apache 2.0 license unless specified. 

open_in_new Go to forum rss_feed Subscribe RSS
visibility 3
thumb_up 0
access_time 17 hours ago

MySQL connector is required which will be used to establish connection to MySQL database. Refer to the following page for more details about installation.  Python: Load Data from MySQL The following code snippet connects to a database named test_db in server localhost (runs on port ...

visibility 2
thumb_up 0
access_time 4 days ago

The following code snippet grants SELECT access (code R) on column id only of table TestDb.test_table to a role named TestRole. grant select (id) on TestDb.test_table to TestRole; To grant SELECT access on multiple columns only, use similar SQL as the following code snippet: grant select ...

visibility 5
thumb_up 0
access_time 4 days ago

Teradata Administrator tool used to have a function to show rights on a database. You can also directly use SQL to query that instead of relying on the GUI tool. select * from dbc.allrights where DatabaseName='TestDb2'; The above code snippet returns all the access rights on a database ...

visibility 4
thumb_up 0
access_time 4 days ago

Teradata Administrator tool used to have a function to show rights held by a database. You can also directly use SQL to query that instead of relying on the GUI tool. select * from dbc.allrights where UserName='TestDb'; The above code snippet returns all the access rights held by database ...

visibility 4
thumb_up 0
access_time 4 days ago

The following code snippet add userA to a role named TestRole : grant TestRole to userA; You can also grant a role to a user with admin option so that the user can drop role, grant and revoke roles from user. grant TestRole to userA with admin option; The above code snippet adds user userA ...

visibility 7
thumb_up 0
access_time 13 days ago

Spark SQL provides functions to calculate covariances of a set of number pairs. There are two functions:  covar_pop(expr1, expr2) and covar_samp(expr1, expr2) . The first one calculates population covariance while the second one calculates sample covariance.  Example: SELECT ...

visibility 11
thumb_up 0
access_time 13 days ago

In Spark SQL, function std or   stddev or    stddev_sample  can be used to calculate sample standard deviation from values of a group.  std(expr) stddev(expr) stddev_samp(expr) The first two functions are the alias of stddev_sample function. SELECT ACCT ...

visibility 8
thumb_up 0
access_time 13 days ago

In Spark SQL, function FIRST_VALUE (FIRST) and LAST_VALUE (LAST) can be used to to find the first or the last value of given column or expression for a group of rows. If parameter `isIgnoreNull` is specified as true, they return only non-null values (unless all values are null). first(expr[ ...

visibility 6
thumb_up 0
access_time 14 days ago

In article  Scala: Parse JSON String as Spark DataFrame , it shows how to convert JSON string to Spark DataFrame; this article show the other way around - convert complex columns to a JSON string using to_json function. Function ' to_json(expr[, options]) ' returns a JSON string with a ...

visibility 11
thumb_up 0
access_time 14 days ago

JSON string values can be extracted using built-in Spark functions like get_json_object or json_tuple.  Values can be extracted using get_json_object function. The function has two parameters: json_txt and path. The first is the JSON text itself, for example a string column in your Spark ...