from typing import Any


def set_common_options(
    spark_source: Any,
    url: str = 'localhost:5432',
    jdbc_table: str = 'default.default',
    user: str = 'root',
    password: str = 'root',
    driver: str = 'driver',
) -> Any:
    """
    Get Spark source from JDBC connection

    :param spark_source: Spark source, here is Spark reader or writer
    :param url: JDBC resource url
    :param jdbc_table: JDBC resource table name
    :param user: JDBC resource user name
    :param password: JDBC resource password
    :param driver: JDBC resource driver
    """
    spark_source = (
        spark_source.format('jdbc')
        .option('url', url)
        .option('dbtable', jdbc_table)
        .option('user', user)
        .option('password', password)
        .option('driver', driver)
    )
    return spark_source