Question: ```
 var Age;

    Age = prompt("How old are you");

    while (Age === null){
        prompt("Please Cofirm You Name");
     if (Age > 0 ){

        break;
     }
    }

```

I am trying to make it so that the user is in a loop until var Age is not null... My goal is to make it so that you cant cancel the prompt and have to type in it. I have tried using the break; in an if statement but its not working.
When I use the break; in an if statement it continues to send the prompt
Is there another way to do this
Or is the value of var Age equal to null(even if you add an integer greater then 0) for some reason and if it is anyone know how to fix it
is there are better way to make to user type in the prompt

Thank You in advanced

Answer: 
spark does not provide any default functions to achieve this kind of functionality

I would do like to do most probably in this way

```
//inputDF contains Col1 | Col2 
val df = inputDF.select("Col1").distinct.rdd.zipWithIndex().toDF("Col1","Col2")
val finalDF = inputDF.join(df,df("Col1") === inputDF("Col1"),"left").select(inputDF("*"),"Col3")

```

but the problem here I can see is **(join which will result in the shuffle)**.

you can also check other autoincrement API's [here](https://spark.apache.org/docs/2.0.2/api/java/org/apache/spark/sql/functions.html#monotonically_increasing_id()).
Use `window` and sum over the window of the value 1 when `Col1 = A`.

```
import pyspark.sql.functions as f
from pyspark.sql import Window

w = Window.partitionBy().rowsBetween(Window.unboundedPreceding, Window.currentRow)

df.withColumn('Col3', f.sum(f.when(f.col('Col1') == f.lit('A'), 1).otherwise(0)).over(w)).show()

+----+-----+----+
|Col1| Col2|Col3|
+----+-----+----+
|   B|  543|   0|
|   A| 1231|   1|
|   B|14234|   1|
|   B|34234|   1|
|   B| 3434|   1|
|   A|43242|   2|
|   B|43242|   2|
|   B|56453|   2|
+----+-----+----+

```