Adding space at the end of a line in Gherkin - gherkin

My question is:
I have a datatable with some values. and i want to the end of one of the values to have a whitespace.
eg.
| Name | Surname | Statement |
| AO | PO | This is a statement |
i want to add a whitespace after the word statement. How can i do that?

Depending on your stepdefinitions (using {string}, {word} or the ^...$ notation) you can do
| Name | Surname | Statement |
| AO | PO | "This is a statement " |
Or use the whitespace character
| Name | Surname | Statement |
| AO | PO | This is a statement\s |

Related

Create SQL SELECT Statement to 'modify' small table

I am pretty new to SQL in general and want to 'modify' the following table (Tablename: translations / PK: id, language, key):
| id | language | key | value |
---------------------------------------------
| 1 | DE | #Keyboard | Tastatur |
| 1 | EN | #Keyboard | Keyboard |
| 1 | ES | #Keyboard | Teclado |
| 2 | DE | #Screen | Bildschirm |
| 2 | EN | #Screen | Screen |
| 3 | ES | #Equipment | Equipo |
I want to get a table like this:
| key | valueDE | valueEN |
--------------------------------------------
| #Keyboard | Tastatur | Keyboard |
| #Screen | Bildschirm | Screen |
| #Equipment | null | null |
So basically I want the translation of the values for the languages DE and EN next to each other in columns. Entries with no translation for DE and EN should have an empty field in the column valueDE and valueEN or if only one translation is available the other field in the column should be empty as shown in the table above.
Help would be appreciated a lot.
Here it is, your definition re-worded into SQL.
select key,
(select value from translations where language='DE' and key=t.key limit 1) "valueDE",
(select value from translations where language='EN' and key=t.key limit 1) "valueEN"
from (select distinct key from translations) t;
key
valueDE
valueEN
#Keyboard
Tastatur
Keyboard
#Equipment
#Screen
Bildschirm
Screen

Loop to find multiple minimum and maximum values

I have a table (tblProduct) with a field (SerialNum).
I am trying to find multiple minimum and maximum values from the field SerialNum, or better put: ranges of sequential serial numbers.
The serial numbers are 5 digits and a letter. Most of the values are sequential, but NOT all!
I need the output for a report to look something like:
00001A - 00014A
00175A - 00180A
00540A - 00549A
12345A - 12349A
04500B - 04503B
04522B - 04529B
04595B
04627B - 04631B
If the values in-between are present.
I tried a loop, but I realized I was using record sets. I need one serial num to be compared to ALL the ranges. Record sets were looking at one range.
I have been able to determine the max and min of the entire series, but not of each sequential group.
| SerialNum |
| -------- |
| 00001A|
| 00002A|
| 00003A|
| 00004A|
| 00005A|
| 00006A|
| 00007A|
| 00008A|
| 00009A|
| 00010A|
| 00011A|
| 00012A|
| 00013A|
| 00014A|
| 00175A|
| 00176A|
| 00177A|
| 00178A|
| 00179A|
| 00180A|
| 00540A|
| 00541A|
| 00542A|
| 00543A|
| 00544A|
| 00545A|
| 00546A|
| 00547A|
| 00548A|
| 00549A|
| 12345A|
| 12346A|
| 12347A|
| 12348A|
| 12349A|
| 04500B|
| 04501B|
| 04502B|
| 04503B|
| 04522B|
| 04523B|
| 04524B|
| 04525B|
| 04526B|
| 04527B|
| 04528B|
| 04529B|
| 04595B|
| 04627B|
| 04628B|
| 04629B|
| 04630B|
| 04631B|
Try to group by the number found with Val:
Select
Min(SerialNum) As MinimumSerialNum,
Max(SerialNum) As MaximumSerialNum
From
tblProduct
Group By
Val(SerialNum)

Create external table from csv on HDFS , all values come with quotes

I have a csv file on HDFS and I am trying to create an impala table , the situation is it created the table and values with all the "
CREATE external TABLE abc.def
(
name STRING,
title STRING,
last STRING,
pno STRING
)
row format delimited fields terminated by ','
location 'hdfs:pathlocation'
tblproperties ("skip.header.line.count"="1") ;
The output is
name tile last pno
"abc" "mr" "xyz" "1234"
"rew" "ms" "pre" "654"
I just want to create table from csv file without quotes. Please guide where I am going wrong.
Regards,
R
A way to do that is creating a stage table that load the file with quotes and then with CTAS (Create table as select) create the right table cleaning the fields with replace function.
As an example
CREATE TABLE quote_stage(
id STRING,
name STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS TEXTFILE;
+-----+----------+
| id | name |
+-----+----------+
| "1" | "pepe" |
| "2" | "ana" |
| "3" | "maria" |
| "4" | "ramon" |
| "5" | "lucia" |
| "6" | "carmen" |
| "7" | "alicia" |
| "8" | "pedro" |
+-----+----------+
CREATE TABLE t_quote
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS TEXTFILE
AS SELECT replace(id,'"','') AS id, replace(name,'"','') AS name FROM quote_stage;
+----+--------+
| id | name |
+----+--------+
| 1 | pepe |
| 2 | ana |
| 3 | maria |
| 4 | ramon |
| 5 | lucia |
| 6 | carmen |
| 7 | alicia |
| 8 | pedro |
+----+--------+
Hope this helps.

Hive: Format string to look like phone number

I have phone numbers saved as text in a column of my table. How can i format it to look like some phone number format using hive.
Phone number Formatted
2076234568 207-623-4568
2079425555 207-942-5555
3178723275 317-872-3275
2072367033 207-236-7033
2077832249 207-783-2249
select Phone_number
,regexp_replace(Phone_number,'(.{3})(.{3})(.{4})','$1-$2-$3') as Formatted
from t
;
+---------------+---------------+
| phone_number | formatted |
+---------------+---------------+
| 2076234568 | 207-623-4568 |
| 2079425555 | 207-942-5555 |
| 3178723275 | 317-872-3275 |
| 2072367033 | 207-236-7033 |
| 2077832249 | 207-783-2249 |
+---------------+---------------+

Replacing multiple strings from a databsae column with distinct replacements

I have a hive table as below:
+----+---------------+-------------+
| id | name | partnership |
+----+---------------+-------------+
| 1 | sachin sourav | first |
| 2 | sachin sehwag | first |
| 3 | sourav sehwag | first |
| 4 | sachin_sourav | first |
+----+---------------+-------------+
In this table I need to replace strings such as "sachin" with "ST" and "Sourav" with "SG". I am using following query, but it is not solving the purpose.
Query:
select
*,
case
when name regexp('\\bsachin\\b')
then regexp_replace(name,'sachin','ST')
when name regexp('\\bsourav\\b')
then regexp_replace(name,'sourav','SG')
else name
end as newName
from sample1;
Result:
+----+---------------+-------------+---------------+
| id | name | partnership | newname |
+----+---------------+-------------+---------------+
| 4 | sachin_sourav | first | sachin_sourav |
| 3 | sourav sehwag | first | SG sehwag |
| 2 | sachin sehwag | first | ST sehwag |
| 1 | sachin sourav | first | ST sourav |
+----+---------------+-------------+---------------+
Problem: My intention is, when id = 1, the newName column should bring value as "ST SG". I mean it should replace both strings.
You can nest the replaces:
select s.*,
replace(replace(s.name, 'sachin', 'ST'), 'sourav', 'SG') as newName
from sample1 s;
You don't need regular expressions, so just use replace().