from pyspark.sql.functions import * customer=spark.sql("Select * FROM workspace.customerdata.customer") display(customer) df.printSchema() df1=df.filter(df["customer_type"]=="VIP") df0=customer.filter(col("customer_type")=="Regular") display(df1) # filter by customer_type and country df1=customer.filter((customer.customer_type=="VIP") & (customer.country=='USA')) # where condition df2=customer.where((customer.customer_type=="VIP") & (customer.country=='USA')) # or operator df3=customer.where((customer.customer_type=="VIP") | (customer.country=='USA'))
Add new column withColumn Function
from pyspark.sql.functions import * customer=spark.sql("Select * FROM workspace.customerdata.customer") customer =customer.withColumn("Salary", col("age")* 1000) customer.printSchema() display(customer)
The oc rsh command in OpenShift allows you to “step inside” a running container and interact with it as if you were using a regular command prompt. It’s like opening a door to the container and being able to run commands and access files inside it.
You need a tool called oc (OpenShift command-line tool) to use oc rsh. It helps you connect to an OpenShift cluster.
You find the container you want to access within a group of containers called a “pod.”
You use the oc rsh a command followed by the pod’s name to enter the container. It’s like opening the door to the container.
Once inside, you can run commands and navigate the container’s files as if you were using a regular command prompt. You can check logs, run scripts, and do other things that the container allows.
When you’re done, you exit the container by typing exit or pressing Ctrl+D. It’s like closing the door behind you.
Remember, it’s important to be careful when using oc rsh it because you can make changes that affect the container and the application running inside it.
OC delete
The oc delete command in OpenShift is used to delete various resources within an OpenShift cluster. It allows you to remove objects like pods, services, deployments, routes, and more.
docker ps -> List all the running docker processes. ps means the process starts
docker run hello-world => docker run image name
docker run – p 80:80 nginx
80:80=> Port 80 on host and port 80 container
nginx is a web server running on port 80
docker stop – container id
docker start container name
Create docker image
# Sample of docker file
# Use a container with Go pre-installed
FROM quay.io/projectquay/golang:1.17
# Copy our source file into the container
COPY src/hello-world.go /go/hello-world.go
# Set the default environment variables
ENV MESSAGE "Welcome! You can change this message by editing the MESSAGE environment variable."
ENV HOME /go
# Set permissions to the /go folder (for OpenShift)
RUN chgrp -R 0 /go && chmod -R g+rwX /go
# Just documentation.
# This container needs Docker or OpenShift to help with networking
EXPOSE 8080
# OpenShift picks up this label and creates a service
LABEL io.openshift.expose-services 8080/http
# OpenShift uses root group instead of root user
USER 1001
# Command to run when container starts up
CMD go run hello-world.go
docker build .
# . current directory
show list of images => docker images
Tag docker image
docker build -t shiva:v1 .
Check the Status of a docker image
docker ps
# show the running container check the status field