def generate_tables_list(tap, as_string=False):
    """
    Generating table names from tap YAMLs in <SCHEMA_NAME>.<TABLE_NAME> format.
    Some tap configurations are required to specify list of tables.

    Example output as list:
        "tables": [
            "MY_SCHEMA.MY_TABLE_1",
            "MY_SCHEMA.MY_TABLE_2"
        ]

    Example output as comma separated string that compatible with tap-snowflake tap
        "tables": "MY_SCHEMA.MY_TABLE_1,MY_SCHEMA.MY_TABLE_2"
    """
    tables_list = []

    # Using the input tap YAML we can generate the required config.json
    schemas = tap.get('schemas', []) if tap else None
    if schemas:
        for schema in schemas:
            tables = schema.get('tables', [])
            for table in tables:
                schema_name = schema['source_schema']
                table_name = table['table_name']

                # Append table name with schema prefix
                tables_list.append(f'{schema_name}.{table_name}')

    # Return as comma separated string
    if as_string:
        return ','.join(tables_list)

    # Return as list
    return tables_list