Posts

Featured Post

SQL Interview Success: Unlocking the Top 5 Frequently Asked Queries

Image
 Here are the five top commonly asked SQL queries in the interviews. These you can expect in Data Analyst, or, Data Engineer interviews. Top SQL Queries for Interviews 01. Joins The commonly asked question pertains to providing two tables, determining the number of rows that will return on various join types, and the resultant. Table1 -------- id ---- 1 1 2 3 Table2 -------- id ---- 1 3 1 NULL Output ------- Inner join --------------- 5 rows will return The result will be: =============== 1  1 1   1 1   1 1    1 3    3 02. Substring and Concat Here, we need to write an SQL query to make the upper case of the first letter and the small case of the remaining letter. Table1 ------ ename ===== raJu venKat kRIshna Solution: ========== SELECT CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2))) AS capitalized_name FROM Table1; 03. Case statement SQL Query ========= SELECT Code1, Code2,      CASE         WHEN Code1 = 'A' AND Code2 = 'AA' THEN "A" | "A

Python Interface Vs. Class: What's the Difference

Image
Here are the differences between Class and Interface in Python. Python class can have all concrete methods. But interface does not have single concrete method. Here you'll know about What's abstract method Abstract Class: How to Create it Rules to Write an Interface How to Create Abstract Class How to Create an Interface What's abstract method The abstrcat method is one which does not have body. from abc import ABC, abstract method class name_class(ABC): # abstract class @abstractmethod def name_method(self): #abstract method without body pass The interface is used when all the features are needed to be implemented differently for different objects. Rules to Write an Interface All methods of an interface should be abstract. You cannot create an interface object. If any class implements an interface, then you need to define all the methods given in that interface in child class. You need to declare all methods as abstract if that class does not implement the interface How to

3 Exclusive Access Modifiers in Python

Image
Here are three access modifiers in Python - Public, Protect, and Private. Access modifiers control the access to a variable/or method.  You may have a question that does python supports access modifiers? The answer is yes. In general, all the variables/or methods are public. Which means accessible to other classes. The private and protect access modifiers will have some rules. And the notation for protect and private are different. The single underscore is for protected and the double underscore is for private. Here is how to find Python list frequent items. Differences between Public, Protect and Private Public access modifier Public variables are accessible outside the class. So in the output, the variables are displayed. class My_employee:     def __init__(self, my_name, my_age):         self.my_name = my_name  #public         self.my_age = my_age   # public my_emp = My_employee('Raj',34) print(my_emp.my_name) print(my_emp.my_age) my_emp.my_name = 'Rohan' print(my_em

How to Send Shell script Result to Email

Image
The shell-script result you can send to email. Below, you will find the steps you need to do it. There are two steps and both will help you know the entire process. Sending shell-script results to email Creating shell-script Sending the result to email 1. Creating shell-script Create an empty script Create test1.sh script using the vi command with the Sudo command. $sudo vi test1.sh Write the first line in the script #!/bin/bash exec > out1.txt 2>&1 Add logic in the shell script #!/bin/bash exec > out1.txt 2>&1 echo" Here is my logic" Provide executable permissions to your script $ sudo chmod +x test1.sh Run your script using the command below $ ./test1.sh Verify the output $ cat out1.txt 2. Sending result to email Use the below command to send the output (result) to email. $ mail <<output file path name>> abc@gmail.com Bottom-line These steps are helpful to send the output to an email.  References How to Install Mailx Utility in Linux

How to Resolve ORA-01722 Invalid Number Error in Oracle SQL Developer

Image
When working with Oracle SQL Developer, you may come across an error message that reads "ORA-01722: invalid number". This error can be frustrating and difficult to understand, especially if you're new to SQL. In this post, I will explain the cause of this error and provide a solution to resolve it. Cause of the Error - ORA-01722 Let's consider an example where we have two tables named "my_hr" and "my_dept". The "my_hr" table contains three columns - "name", "pay_id", and "user_id", while the "my_dept" table contains two columns - "name" and "user_id". CREATE TABLE my_hr ( name CHAR(20), pay_id NUMBER, user_id CHAR(6) ); CREATE TABLE my_dept ( name CHAR(20), user_id CHAR(6) ); Now, let's insert some sample data into these tables: INSERT INTO my_hr VALUES ('Srini', 567, '123456'); INSERT INTO my_dept VALUES ('Srini', '123456'); If we try to execu

Here's Python Program for List Duplicates

Image
Here is a program to find the item that occurs most frequently in a data structure. So why to find frequent item? Maybe it is the most purchased item on your shopping site. Perhaps it is the web page that gets hit the most often. If you are a tester, it could easily be the test that has had the most failures over the last year. Whatever it is, you want an easy way to find the data you need, and Python is here to help you. Python List duplicates Here are the two simple lists: list_1 = [1,2,3,2,3,2]  list_2 = ['a', 'b', 'a', 'b', 'c'] We can't do simple math on the individual items  since the second list contains characters. For example, it could contain the words of a book, and you want to find the most commonly used word in the work.  Also, it maybe list of UPC values for commonly purchased items. Whatever it is, all we can guarantee is that the data is probably comparable, in that we can compare one of the items to another. Yet we need to f

2 Exclusive Ways to Start Kafka Services

Image
The Kafka services start or stop you can do in two ways. Those are  Systemd  and  Systemctl  (sudo user). Below, you will find the commands for these two methods. How to start/stop Kafka service Here are exclusive ways. With these, you can start or stop Kafka services .   1. Systemd service The concept of unit files people who worked on Linux servers have familiarity with it. Also, they know creating the unit file to use by systemd. To summarize,  it initializes and maintains components throughout the system . This means that you can define ZooKeeper and Kafka as unit files, which then will be used by systems. Commands The first command starts the service, and the second command stops the service. ... [Service] ... ExecStart=/opt/kafkainaction/bin/zookeeper-server-start.sh ExecStop= /opt/kafkainaction/bin/zookeeper-server-stop.sh 2. Systemctl by Sudo (root) user The root user can start or stop the Kafka services. This is more like front-end processing. This way of executing is called

How to Retain data in Kafka and Get Additional Time for Analysis

Image
The default topic retention period in Kafka is seven days. However, you can change the current retention period and keep data for a few more days. Hence it provides you additional time for analysis to get business insights. Kafka retention period The retention period, you can set on two parameters of bytes and time. Due to cheap storage costs, companies wish to extend the data retention period.  The retention period setup you need in the broker.  It is not a deviation that Kafka is designed only for Seven days, and why we need to change it. Since space is cheaper, we can extend the retention period. Setup for the retention period Below is the setup in the broker configuration file for the retention period. log.retention.bytes The most significant size threshold in bytes for deleting a log. log.retention.ms The length in milliseconds of a log will be maintained before being deleted. log.retention.minutes Length before deletion in minutes. log.retention.ms is used as well if both are set