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

Load Balancers in AWS: Choosing the Right Option for Your Application

Image
The load balancer's purpose is to balance the incoming traffic. It allocates the incoming traffic to the available healthy servers. Here are the top AWS load balancers. AWS Load balancers These are Application Load Balancer, Gateway Load Balancer, and Network Load Balancer. Application Load Balancers Gateway Load Balancers Network Load Balancers   1. Application Load Balancers (ALB) A Load balancer contains two parts - Listeners and Target groups. The listener then connects to a target group. The listener first checks the availability of connection according to the IP address and Port you did configure. Adopted from Amazon AWS   2. Gateway Load Balancers (GWLB) A Gateway Load Balancer receives traffic from the source and sends the traffic to targets. It sends requests to multiple virtual appliances. It's the prime difference between ALB and GWLB. 3. Network Load Balancers (NLB) A Network Load Balancer functions at the fourth layer of the Open Systems Interconnection (OSI) model

How to Create an Array and Its Types in Python

Image
Python supports various array types. Here is a list of arrays and how to create examples for your reference.  What is an array? A  Python array  is a class that mimics the array type of other languages and offers efficiency in storage, exchanging that for flexibility. How to create an array Here is the syntax to create an array: data = array('f', [12.8, 5.4, 8.0, 8.0, 9.21, 3.14]) It creates an array of 6 floating point numbers; the type is indicated by the 'f' as the first parameter to the constructor. This concept is unlike the Python norm of types being dynamic and malleable. An array is an array of one kind of thing, and an array can only hold a restricted set of types. Types of arrays Here is a list of arrays: 'b' A C++ char type 'B' A C++ unsigned char type 'i': A C++ int type 'l': A C++ long type 'f': A C++ float type 'd': A C++ double type What is an array type? Arrays are class objects and are provided in the buil

How to Find Folder Space in Linux Easily

Image
Here's an example that shows how to use find command to get directory utilized space in Linux. Many of a time during production support, or when crontab jobs failed, the reasons behind is space shortage of a directory. The find is handy you can use to get utilized space of a directory. That helps you to delete unnecessary files (that actually make some space). Linux find command Here's the find command that I  have used in our project . You will find here the detailed explanation of this command and how to use it. find  /home/srini -xdev -ls | sort +6rn | head -20 Part#1: Directory path In the first part,  after the find you need to give the directory's path for which  folder you are going to find  space. Part#2: Option -xdev The second part is  -xdev , which gives the space usage of all the subdirectories. Part#3: Option -ls The next part is the -ls option that provides a sorted list of all the subdirectories.  Part#4: Sort command Then, the sort command sorts based on the

Tail Command in Linux: A Comprehensive Overview

Image
The tail in Linux is handy command. You can check the last lines of a file in Linux/Unix operating systems. You can use it to display last lines from single file, display last lines from multiple files, display the last entries of log files. Tail Command in Linux During production support the usage of Tail command is helpful since you can check latest logs quickly. Here are the top Tail command examples. #1 Display last lines in a file (Tail file Linux) Here's the tail command that shows last three lines of a file. cat sample.txt | tail -3 It displays last 3 lines of a file. The same command you can use as tail -3 sample.txt #2 Display last lines of multiple files There are three files. sample2.txt, sample3.txt, sample4.txt. The command displays the last 3 lines from all the three files. tail -3 sample[2-4].txt #3 Tail -f option (Tail f Linux) The –f option is to check status of long-running process that is redirecting output to a file. For example, if you invoke the below command

How to Use Arguments in Real Python Programs

Image
Here are four types of exclusive arguments in python. The arguments are passers to functions. These are Required arguments, Keyword arguments, Default arguments and Variable-length arguments. Here're 4 Important Arguments in Python The arguments supply input to functions . Because these are various types, herein you will know the details and usage of those types. Argument#1: Required arguments Positional arguments are known as  required arguments  and are passed to a function in the correct order. The arguments in the function call should match the number in the function definition. Sample program: def cal(a,b):     """program to calculate sum of 2 numbers"""     sum=a+b     return sum a=int(input("enter 1st number")) b=int(input("enter 2nd number")) print(cal(a,b)) Output enter 1st number 10 enter 2nd number 22 32 ** Process exited - Return Code: 0 ** Press Enter to exit terminal Argument#2: Keyword arguments A default argument is

How to Monitor Kafka-stream's Performance

Image
Kafka Streams API is a part of Kafka, it goes without saying that monitoring your application will require some monitoring of Kafka as well. Performance The consumer and producer performance is one of the fundamental performance concerns for a producer and consumer.   The Kafka data flow diagram What is lag For producers, we care mostly about how fast the producer is sending messages to the broker. Obviously, the higher the throughput, the better. For consumers, we’re also concerned with performance, or how fast we can read messages from a broker. we care about how much and how fast our producers can publish to a broker, and we simultaneously care about how quickly our consumers can read those messages from the broker. The difference between how fast the producers place records on the broker and when consumers read those messages is called consumer lag How to check consumer lag To check for consumer lag, Kafka provides a convenient command-line tool, kafka-consumer-groups.sh, found in

How to Read CSV file Data in Python

Image
Here is a way to read  CSV files  in Python pandas. The packages you need to import are numpy and pandas. On the flip side, f or Text files, you don't need to import these special libraries since python by default support it. Python pandas read_csv >>> import numpy as np >>> import pandas as pd To see how pandas handle this kind of data, we'll create a small CSV file in the working directory as ch05_01.csv. white, red, blue, green, animal 1,5,2,3,cat  2,7,8,5,dog  3,3,6,7,horse  2,2,8,3,duck  4,4,2,1,mouse Since this file is comma-delimited , you can use the read_csv() function to read its content and convert it to a dataframe object. >>> csvframe = pd.read_csv('ch05_01.csv') >>> csvframe white red blue green animal 0 1 5 2 3 cat 1 2 7 8 5 dog 2 3 3 6 7 horse 3 2 2 8 3 duck 4 4 4 2 1 mouse Python reading text files Since python supp